Submission #140583

#TimeUsernameProblemLanguageResultExecution timeMemory
140583khrbuddy03사냥꾼 (KOI13_hunter)C++14
100 / 100
63 ms4728 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...