Submission #76050

#TimeUsernameProblemLanguageResultExecution timeMemory
76050chunghan사냥꾼 (KOI13_hunter)C++14
48 / 100
162 ms1804 KiB
#include<iostream> #include<algorithm> #include<math.h> using namespace std; typedef pair<int, int> pii; int m, n, l, x[100000], cnt; pii ani[100000]; int dist(int a, int x) { return abs(x - ani[a].first) + ani[a].second; } int find(int a) { int start = 0, end = m-1; int mid, rst, ld, hd; bool find = false; while(start <= end) { mid = (start+end)/2; if(x[mid] < a) start = mid+1; else if(x[mid] > a) end = mid-1; else { rst = mid; find = true; break; } } if(!find) { ld = abs(a-x[start]); hd = abs(a-x[end]); rst = ld < hd ? start : end; } return rst; } int main() { cin >> m >> n >> l; for(int i = 0; i < m; i++) cin >> x[i]; for(int i = 0, a, b; i < n; i++) { cin >> a >> b; ani[i] = pii(a, b); } sort(x, x+m); for(int i = 0; i < n; i++) if(dist(i, x[find(ani[i].first)]) <= l) cnt++; cout << cnt; return 0; }
#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...