#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
424 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
700 KB |
Output is correct |
5 |
Correct |
2 ms |
700 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
700 KB |
Output is correct |
8 |
Correct |
2 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
700 KB |
Output is correct |
2 |
Correct |
2 ms |
700 KB |
Output is correct |
3 |
Correct |
2 ms |
700 KB |
Output is correct |
4 |
Correct |
2 ms |
700 KB |
Output is correct |
5 |
Correct |
2 ms |
700 KB |
Output is correct |
6 |
Correct |
2 ms |
700 KB |
Output is correct |
7 |
Correct |
2 ms |
700 KB |
Output is correct |
8 |
Correct |
2 ms |
700 KB |
Output is correct |
9 |
Correct |
2 ms |
700 KB |
Output is correct |
10 |
Correct |
2 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
700 KB |
Output is correct |
2 |
Correct |
3 ms |
700 KB |
Output is correct |
3 |
Correct |
3 ms |
700 KB |
Output is correct |
4 |
Incorrect |
4 ms |
700 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
2072 KB |
Output is correct |
2 |
Correct |
121 ms |
2208 KB |
Output is correct |
3 |
Correct |
131 ms |
2428 KB |
Output is correct |
4 |
Correct |
114 ms |
2428 KB |
Output is correct |
5 |
Correct |
160 ms |
2812 KB |
Output is correct |
6 |
Incorrect |
157 ms |
2812 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |