-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApartment.cpp
More file actions
41 lines (41 loc) · 820 Bytes
/
Copy pathApartment.cpp
File metadata and controls
41 lines (41 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "bits/stdc++.h"
// #include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,k;
cin>>n;
cin>>m;
cin>>k;
int arr[n];
int brr[m];
for(int i=0;i<n;i++){
int num;
cin>>num;
arr[i]=num;
}
for(int i=0;i<m;i++){
int num;
cin>>num;
brr[i]=num;
}
sort(arr,arr+n);
sort(brr,brr+m);
int res=0;
int j=0;
for(int i=0;i<m;i++){
while(j<n){
if(brr[i]-arr[j]<-k){
break;
}
else if(brr[i]-arr[j]>=-k&&brr[i]-arr[j]<=k){
j++;
res++;
break;
}
else{
j++;
}
}
}
cout<<res<<endl;
}