#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> point;
const int inf = 1e5 + 9;
int dist(point& p1, point& p2) {
return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}
point gun[inf];
point ani[inf];
int main() {
#if DEBUG
// //freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int m, n, l; cin >> m >> n >> l;
for (int i = 0; i < m; i++) cin >> gun[i].first;
for (int i = 0; i < n; i++) cin >> ani[i].first >> ani[i].second;
sort(gun, gun + m);
sort(ani, ani + n);
int ans = 0;
int pos = 0;
for (int i = 0; i < n; i++) {
while (gun[pos].first <= ani[i].first && pos < m) pos++;
if (pos - 1 < 0) {
if (dist(ani[i], gun[pos]) <= l) {
ans++;
}
} else {
if (dist(ani[i], gun[pos - 1]) <= l || dist(ani[i], gun[pos]) <= l) {
ans++;
}
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
420 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
2856 KB |
Output is correct |
2 |
Correct |
44 ms |
3384 KB |
Output is correct |
3 |
Correct |
49 ms |
3704 KB |
Output is correct |
4 |
Correct |
43 ms |
3320 KB |
Output is correct |
5 |
Correct |
59 ms |
4400 KB |
Output is correct |
6 |
Correct |
60 ms |
4472 KB |
Output is correct |
7 |
Correct |
63 ms |
4728 KB |
Output is correct |
8 |
Correct |
50 ms |
3856 KB |
Output is correct |
9 |
Correct |
62 ms |
4728 KB |
Output is correct |
10 |
Correct |
60 ms |
4600 KB |
Output is correct |