-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1084.cpp
More file actions
39 lines (37 loc) · 679 Bytes
/
1084.cpp
File metadata and controls
39 lines (37 loc) · 679 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
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<long int> a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
vector<long int> b(m);
for (int i = 0; i < m; i++)
{
cin >> b[i];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
int count = 0;
int j = 0;
for (int i = 0; i < n; i++)
{
while (j < m && b[j] < a[i] - k)
{
j++;
}
if (j < m && b[j] <= a[i] + k)
{
count++;
j++;
}
}
cout << count << endl;
}