This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |