Skip to content

Commit 89921c6

Browse files
committed
solved 8983
1 parent 9220a8a commit 89921c6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

8000/8983/8983.cpp

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <algorithm> //sort
2+
#include <iostream>
3+
#include <utility> //pair
4+
#include <vector>
5+
using namespace std;
6+
7+
typedef pair<int, int> pii;
8+
9+
#define reap(i, a, b) for (int i = a; i < b; i++)
10+
#define in1(a) cin >> a;
11+
#define in2(a, b) cin >> a >> b;
12+
#define in3(a, b, c) cin >> a >> b >> c;
13+
#define out1(a) cout << a << endl;
14+
15+
#define MAX (1000000001)
16+
17+
int M, N, L, gun[1000000];
18+
vector<pii> range;
19+
20+
int main() {
21+
ios::sync_with_stdio(false);
22+
cin.tie(NULL);
23+
24+
in3(M, N, L);
25+
reap(i, 0, M) in1(gun[i]);
26+
27+
reap(i, 0, N){
28+
int x, y;
29+
in2(x, y);
30+
if(L < y) continue;
31+
range.push_back(make_pair(x - (L - y), x + (L - y)));
32+
}
33+
34+
sort(gun, gun + M);
35+
sort(range.begin(), range.end());
36+
37+
int j = 0;
38+
int res = 0;
39+
40+
reap(i, 0, M){
41+
int x = gun[i];
42+
while(true){
43+
if(j >= range.size()) break;
44+
45+
if(range[j].second < x) ++j;
46+
else if(range[j].first <= x){
47+
++res;
48+
++j;
49+
}else {
50+
break;
51+
}
52+
}
53+
}
54+
55+
out1(res);
56+
57+
return 0;
58+
}

0 commit comments

Comments
 (0)