# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
269545 |
2020-08-17T07:44:58 Z |
sean9892 |
None (KOI18_XCorr) |
C++14 |
|
208 ms |
21728 KB |
#include<bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
const int inf=2e9;
vector<pii> x,y;
vector<int> p;
ll sum[300010];
int main(void){
ios::sync_with_stdio(0);cin.tie(0);
int n,m;
cin>>n;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
x.emplace_back(a,b);
}
cin>>m;
p.push_back(-inf);
sum[0]=0;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
y.emplace_back(a,b);
p.push_back(a);
sum[i+1]=b;
sum[i+1]+=sum[i];
}
sum[m+1]=sum[m];
p.push_back(inf);
int a,b;
cin>>a>>b;
ll res=0;
for(int i=0;i<n;i++){
int k=x[i].first,r=x[i].second;
int ub,s,e;
ub=upper_bound(p.begin(),p.end(),k+a-1)-p.begin();
s=sum[ub-1];
ub=upper_bound(p.begin(),p.end(),k+b)-p.begin();
e=sum[ub-1];
res+=1ll*r*(e-s);
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
83 ms |
11112 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
150 ms |
19508 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
412 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
147 ms |
18448 KB |
Output is correct |
25 |
Correct |
177 ms |
19776 KB |
Output is correct |
26 |
Correct |
142 ms |
19472 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
149 ms |
19424 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
159 ms |
18888 KB |
Output is correct |
33 |
Correct |
142 ms |
19424 KB |
Output is correct |
34 |
Correct |
72 ms |
10764 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
145 ms |
19424 KB |
Output is correct |
37 |
Correct |
53 ms |
4208 KB |
Output is correct |
38 |
Correct |
2 ms |
512 KB |
Output is correct |
39 |
Correct |
149 ms |
18656 KB |
Output is correct |
40 |
Correct |
2 ms |
512 KB |
Output is correct |
41 |
Correct |
1 ms |
384 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
83 ms |
11112 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
150 ms |
19508 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
412 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
147 ms |
18448 KB |
Output is correct |
25 |
Correct |
177 ms |
19776 KB |
Output is correct |
26 |
Correct |
142 ms |
19472 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
149 ms |
19424 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
159 ms |
18888 KB |
Output is correct |
33 |
Correct |
142 ms |
19424 KB |
Output is correct |
34 |
Correct |
72 ms |
10764 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
145 ms |
19424 KB |
Output is correct |
37 |
Correct |
53 ms |
4208 KB |
Output is correct |
38 |
Correct |
2 ms |
512 KB |
Output is correct |
39 |
Correct |
149 ms |
18656 KB |
Output is correct |
40 |
Correct |
2 ms |
512 KB |
Output is correct |
41 |
Correct |
1 ms |
384 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
82 ms |
11204 KB |
Output is correct |
45 |
Correct |
3 ms |
512 KB |
Output is correct |
46 |
Correct |
149 ms |
19424 KB |
Output is correct |
47 |
Correct |
2 ms |
544 KB |
Output is correct |
48 |
Correct |
158 ms |
15208 KB |
Output is correct |
49 |
Correct |
67 ms |
7516 KB |
Output is correct |
50 |
Correct |
2 ms |
512 KB |
Output is correct |
51 |
Correct |
2 ms |
512 KB |
Output is correct |
52 |
Correct |
1 ms |
384 KB |
Output is correct |
53 |
Correct |
2 ms |
512 KB |
Output is correct |
54 |
Correct |
187 ms |
18400 KB |
Output is correct |
55 |
Correct |
208 ms |
19712 KB |
Output is correct |
56 |
Correct |
187 ms |
21728 KB |
Output is correct |
57 |
Correct |
139 ms |
19424 KB |
Output is correct |
58 |
Correct |
151 ms |
21344 KB |
Output is correct |
59 |
Correct |
2 ms |
512 KB |
Output is correct |
60 |
Correct |
1 ms |
384 KB |
Output is correct |
61 |
Correct |
2 ms |
512 KB |
Output is correct |
62 |
Correct |
160 ms |
21348 KB |
Output is correct |
63 |
Correct |
169 ms |
21416 KB |
Output is correct |
64 |
Correct |
1 ms |
384 KB |
Output is correct |
65 |
Correct |
165 ms |
21560 KB |
Output is correct |
66 |
Correct |
176 ms |
19548 KB |
Output is correct |
67 |
Correct |
181 ms |
20696 KB |
Output is correct |
68 |
Correct |
2 ms |
512 KB |
Output is correct |
69 |
Correct |
168 ms |
18908 KB |
Output is correct |
70 |
Correct |
98 ms |
8368 KB |
Output is correct |
71 |
Correct |
170 ms |
21088 KB |
Output is correct |
72 |
Correct |
153 ms |
19680 KB |
Output is correct |
73 |
Correct |
62 ms |
10812 KB |
Output is correct |
74 |
Correct |
1 ms |
384 KB |
Output is correct |
75 |
Correct |
171 ms |
19416 KB |
Output is correct |
76 |
Correct |
63 ms |
4208 KB |
Output is correct |
77 |
Correct |
2 ms |
512 KB |
Output is correct |
78 |
Correct |
133 ms |
18656 KB |
Output is correct |
79 |
Correct |
1 ms |
384 KB |
Output is correct |
80 |
Correct |
2 ms |
512 KB |
Output is correct |
81 |
Correct |
1 ms |
384 KB |
Output is correct |
82 |
Correct |
152 ms |
21348 KB |
Output is correct |
83 |
Correct |
1 ms |
384 KB |
Output is correct |
84 |
Correct |
1 ms |
384 KB |
Output is correct |
85 |
Correct |
160 ms |
20832 KB |
Output is correct |