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 pair<int, int> pii;
int m, n, l, x[100000], cnt, c[100000];
pii ani[100000];
int dist(int a, int x) {
return abs(x - ani[a].first) + ani[a].second;
}
void find() {
int k = 0;
for(int i = 0; i < n; i++) {
if(abs(ani[i].first-x[k]) > abs(ani[i].first-x[k+1]))
k++;
c[i] = k;
}
}
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);
find();
for(int i = 0; i < n; i++)
if(dist(i, x[c[i]]) <= l) 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... |