Submission #76048

#TimeUsernameProblemLanguageResultExecution timeMemory
76048chunghan사냥꾼 (KOI13_hunter)C++14
48 / 100
160 ms2812 KiB
#include<iostream> #include<algorithm> #include<math.h> using namespace std; typedef long long int lld; typedef pair<lld, lld> pii; lld m, n, l, x[100000], cnt; pii ani[100000]; lld 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 = 0, hd = 0; 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); //sort(ani, ani+n); //cout << x[find(7)] << endl; for(int i = 0; i < n; i++) { //cout << dist(i, x[find(ani[i].first)]) << ' ' << x[find(ani[i].first)] << ' ' << ani[i].first << ' ' << ani[i].second << endl; if(dist(i, x[find(ani[i].first)]) <= l) { //cout << ani[i].first << ' ' << ani[i].second << endl; 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...