-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1084.cpp
48 lines (41 loc) · 879 Bytes
/
1084.cpp
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
42
43
44
45
46
47
48
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define endl "\n"
int main()
{
ll i, n, m, k;
cin >> n >> m >> k;
ll a[n], b[m];
for(i = 0; i < n; i++)
{
cin >> a[i];
}
for(i = 0; i < m; i++)
{
cin >> b[i];
}
sort(a, a + n);
sort(b, b + m);
ll j = 0, ans = 0;
i = 0;
while(i < n and j < m)
{
if(a[i] < b[j] - k)
{
i++;
}
else if(a[i] > b[j] + k)
{
j++;
}
else
{
i++;
j++;
ans++;
}
}
cout << ans << endl;
return 0;
}