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<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 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... |