이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |