#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
int n, m;
int seg[1 << 20];
pii xs[300000];
pii ys[300000];
void init(int i, int s, int e) {
if (s == e) {
seg[i] = xs[s].second;
return;
}
int m = (s + e) / 2;
init(i << 1, s, m);
init(i << 1 | 1, m + 1, e);
seg[i] = seg[i << 1] + seg[i << 1 | 1];
}
int query(int i, int s, int e, int x, int y) {
if (xs[e].first < x || y < xs[s].first) return 0;
if (x <= xs[s].first && xs[e].first <= y) return seg[i];
int m = (s + e) / 2;
return query(i << 1, s, m, x, y) + query(i << 1 | 1, m + 1, e, x, y);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> xs[i].first >> xs[i].second;
}
init(1, 0, n - 1);
cin >> m;
for (int i = 0; i < m; ++i) {
cin >> ys[i].first >> ys[i].second;
}
int a, b;
cin >> a >> b;
llong ans = 0;
for (int i = 0; i < m; ++i) {
ans += (llong)ys[i].second
* query(1, 0, n - 1, ys[i].first - b, ys[i].first - a);
}
printf("%lld\n", ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
544 KB |
Output is correct |
3 |
Correct |
4 ms |
804 KB |
Output is correct |
4 |
Correct |
5 ms |
804 KB |
Output is correct |
5 |
Correct |
2 ms |
804 KB |
Output is correct |
6 |
Correct |
5 ms |
932 KB |
Output is correct |
7 |
Correct |
3 ms |
992 KB |
Output is correct |
8 |
Correct |
4 ms |
1176 KB |
Output is correct |
9 |
Correct |
3 ms |
1176 KB |
Output is correct |
10 |
Correct |
4 ms |
1176 KB |
Output is correct |
11 |
Correct |
2 ms |
1176 KB |
Output is correct |
12 |
Correct |
5 ms |
1208 KB |
Output is correct |
13 |
Correct |
4 ms |
1264 KB |
Output is correct |
14 |
Correct |
3 ms |
1264 KB |
Output is correct |
15 |
Correct |
3 ms |
1264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
544 KB |
Output is correct |
3 |
Correct |
4 ms |
804 KB |
Output is correct |
4 |
Correct |
5 ms |
804 KB |
Output is correct |
5 |
Correct |
2 ms |
804 KB |
Output is correct |
6 |
Correct |
5 ms |
932 KB |
Output is correct |
7 |
Correct |
3 ms |
992 KB |
Output is correct |
8 |
Correct |
4 ms |
1176 KB |
Output is correct |
9 |
Correct |
3 ms |
1176 KB |
Output is correct |
10 |
Correct |
4 ms |
1176 KB |
Output is correct |
11 |
Correct |
2 ms |
1176 KB |
Output is correct |
12 |
Correct |
5 ms |
1208 KB |
Output is correct |
13 |
Correct |
4 ms |
1264 KB |
Output is correct |
14 |
Correct |
3 ms |
1264 KB |
Output is correct |
15 |
Correct |
3 ms |
1264 KB |
Output is correct |
16 |
Correct |
99 ms |
8168 KB |
Output is correct |
17 |
Correct |
4 ms |
8168 KB |
Output is correct |
18 |
Correct |
146 ms |
12160 KB |
Output is correct |
19 |
Correct |
3 ms |
12160 KB |
Output is correct |
20 |
Correct |
4 ms |
12160 KB |
Output is correct |
21 |
Correct |
4 ms |
12160 KB |
Output is correct |
22 |
Correct |
2 ms |
12160 KB |
Output is correct |
23 |
Correct |
5 ms |
12160 KB |
Output is correct |
24 |
Correct |
213 ms |
12160 KB |
Output is correct |
25 |
Correct |
129 ms |
12288 KB |
Output is correct |
26 |
Correct |
146 ms |
12288 KB |
Output is correct |
27 |
Correct |
3 ms |
12288 KB |
Output is correct |
28 |
Correct |
4 ms |
12288 KB |
Output is correct |
29 |
Correct |
3 ms |
12288 KB |
Output is correct |
30 |
Correct |
139 ms |
12288 KB |
Output is correct |
31 |
Correct |
5 ms |
12288 KB |
Output is correct |
32 |
Correct |
181 ms |
12288 KB |
Output is correct |
33 |
Correct |
144 ms |
12304 KB |
Output is correct |
34 |
Correct |
73 ms |
12304 KB |
Output is correct |
35 |
Correct |
2 ms |
12304 KB |
Output is correct |
36 |
Correct |
129 ms |
12304 KB |
Output is correct |
37 |
Correct |
42 ms |
12304 KB |
Output is correct |
38 |
Correct |
3 ms |
12304 KB |
Output is correct |
39 |
Correct |
117 ms |
12304 KB |
Output is correct |
40 |
Correct |
4 ms |
12304 KB |
Output is correct |
41 |
Correct |
3 ms |
12304 KB |
Output is correct |
42 |
Correct |
3 ms |
12304 KB |
Output is correct |
43 |
Correct |
2 ms |
12304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
544 KB |
Output is correct |
3 |
Correct |
4 ms |
804 KB |
Output is correct |
4 |
Correct |
5 ms |
804 KB |
Output is correct |
5 |
Correct |
2 ms |
804 KB |
Output is correct |
6 |
Correct |
5 ms |
932 KB |
Output is correct |
7 |
Correct |
3 ms |
992 KB |
Output is correct |
8 |
Correct |
4 ms |
1176 KB |
Output is correct |
9 |
Correct |
3 ms |
1176 KB |
Output is correct |
10 |
Correct |
4 ms |
1176 KB |
Output is correct |
11 |
Correct |
2 ms |
1176 KB |
Output is correct |
12 |
Correct |
5 ms |
1208 KB |
Output is correct |
13 |
Correct |
4 ms |
1264 KB |
Output is correct |
14 |
Correct |
3 ms |
1264 KB |
Output is correct |
15 |
Correct |
3 ms |
1264 KB |
Output is correct |
16 |
Correct |
99 ms |
8168 KB |
Output is correct |
17 |
Correct |
4 ms |
8168 KB |
Output is correct |
18 |
Correct |
146 ms |
12160 KB |
Output is correct |
19 |
Correct |
3 ms |
12160 KB |
Output is correct |
20 |
Correct |
4 ms |
12160 KB |
Output is correct |
21 |
Correct |
4 ms |
12160 KB |
Output is correct |
22 |
Correct |
2 ms |
12160 KB |
Output is correct |
23 |
Correct |
5 ms |
12160 KB |
Output is correct |
24 |
Correct |
213 ms |
12160 KB |
Output is correct |
25 |
Correct |
129 ms |
12288 KB |
Output is correct |
26 |
Correct |
146 ms |
12288 KB |
Output is correct |
27 |
Correct |
3 ms |
12288 KB |
Output is correct |
28 |
Correct |
4 ms |
12288 KB |
Output is correct |
29 |
Correct |
3 ms |
12288 KB |
Output is correct |
30 |
Correct |
139 ms |
12288 KB |
Output is correct |
31 |
Correct |
5 ms |
12288 KB |
Output is correct |
32 |
Correct |
181 ms |
12288 KB |
Output is correct |
33 |
Correct |
144 ms |
12304 KB |
Output is correct |
34 |
Correct |
73 ms |
12304 KB |
Output is correct |
35 |
Correct |
2 ms |
12304 KB |
Output is correct |
36 |
Correct |
129 ms |
12304 KB |
Output is correct |
37 |
Correct |
42 ms |
12304 KB |
Output is correct |
38 |
Correct |
3 ms |
12304 KB |
Output is correct |
39 |
Correct |
117 ms |
12304 KB |
Output is correct |
40 |
Correct |
4 ms |
12304 KB |
Output is correct |
41 |
Correct |
3 ms |
12304 KB |
Output is correct |
42 |
Correct |
3 ms |
12304 KB |
Output is correct |
43 |
Correct |
2 ms |
12304 KB |
Output is correct |
44 |
Correct |
94 ms |
12304 KB |
Output is correct |
45 |
Correct |
4 ms |
12304 KB |
Output is correct |
46 |
Correct |
127 ms |
12304 KB |
Output is correct |
47 |
Correct |
3 ms |
12304 KB |
Output is correct |
48 |
Correct |
128 ms |
12304 KB |
Output is correct |
49 |
Correct |
64 ms |
12304 KB |
Output is correct |
50 |
Correct |
4 ms |
12304 KB |
Output is correct |
51 |
Correct |
4 ms |
12304 KB |
Output is correct |
52 |
Correct |
2 ms |
12304 KB |
Output is correct |
53 |
Correct |
3 ms |
12304 KB |
Output is correct |
54 |
Correct |
176 ms |
12304 KB |
Output is correct |
55 |
Correct |
121 ms |
12304 KB |
Output is correct |
56 |
Correct |
163 ms |
12328 KB |
Output is correct |
57 |
Correct |
125 ms |
12328 KB |
Output is correct |
58 |
Correct |
143 ms |
12328 KB |
Output is correct |
59 |
Correct |
3 ms |
12328 KB |
Output is correct |
60 |
Correct |
2 ms |
12328 KB |
Output is correct |
61 |
Correct |
4 ms |
12328 KB |
Output is correct |
62 |
Correct |
163 ms |
12328 KB |
Output is correct |
63 |
Correct |
145 ms |
12328 KB |
Output is correct |
64 |
Correct |
3 ms |
12328 KB |
Output is correct |
65 |
Correct |
171 ms |
12328 KB |
Output is correct |
66 |
Correct |
129 ms |
12368 KB |
Output is correct |
67 |
Correct |
185 ms |
12368 KB |
Output is correct |
68 |
Correct |
4 ms |
12368 KB |
Output is correct |
69 |
Correct |
176 ms |
12368 KB |
Output is correct |
70 |
Correct |
81 ms |
12368 KB |
Output is correct |
71 |
Correct |
193 ms |
12368 KB |
Output is correct |
72 |
Correct |
165 ms |
12368 KB |
Output is correct |
73 |
Correct |
71 ms |
12368 KB |
Output is correct |
74 |
Correct |
3 ms |
12368 KB |
Output is correct |
75 |
Correct |
159 ms |
12368 KB |
Output is correct |
76 |
Correct |
43 ms |
12368 KB |
Output is correct |
77 |
Correct |
3 ms |
12368 KB |
Output is correct |
78 |
Correct |
138 ms |
12368 KB |
Output is correct |
79 |
Correct |
2 ms |
12368 KB |
Output is correct |
80 |
Correct |
4 ms |
12368 KB |
Output is correct |
81 |
Correct |
2 ms |
12368 KB |
Output is correct |
82 |
Correct |
158 ms |
12368 KB |
Output is correct |
83 |
Correct |
3 ms |
12368 KB |
Output is correct |
84 |
Correct |
2 ms |
12368 KB |
Output is correct |
85 |
Correct |
217 ms |
12368 KB |
Output is correct |