# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
396927 |
2021-05-01T01:52:51 Z |
AQT |
Snowball (JOI21_ho_t2) |
C++14 |
|
132 ms |
9796 KB |
#include <bits/stdc++.h>
using namespace std;
int N, Q;
long long x[200005];
long long w[200005];
long long d[200005];
long long lft[200005], rht[200005];
long long ans[200005];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> Q;
for(int i = 1; i <= N; i++){
cin >> x[i];
}
for(int i = 1; i <= Q; i++){
cin >> d[i];
d[i] += d[i-1];
}
for(int i = 1; i <= Q; i++){
if(d[i] < 0){
rht[i] = -d[i];
}
else{
lft[i] = d[i];
}
rht[i] = max(rht[i], rht[i-1]);
lft[i] = max(lft[i], lft[i-1]);
}
ans[1] = rht[Q];
ans[N] += lft[Q];
for(int i = 1; i < N; i++){
if(lft[Q] + rht[Q] > x[i + 1] - x[i]){
int l = 1, r = Q, k = 0;
while(l <= r){
int mid = (l + r)/2;
if(lft[mid] + rht[mid] < x[i + 1] - x[i]){
l = mid + 1;
}
else{
r = mid - 1;
k = mid;
}
}
ans[i] += lft[k-1];
ans[i+1] += rht[k-1];
if(lft[k-1] != lft[k]){
ans[i] += x[i + 1] - x[i] - lft[k-1] - rht[k-1];
}
else{
ans[i+1] += x[i+1] - x[i] - lft[k-1] - rht[k-1];
}
}
else{
ans[i] += lft[Q];
ans[i+1] += rht[Q];
}
}
for(int i = 1; i <= N; i++){
cout << ans[i];
if(i != N){
cout << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
30 ms |
4920 KB |
Output is correct |
21 |
Correct |
30 ms |
4972 KB |
Output is correct |
22 |
Correct |
29 ms |
4948 KB |
Output is correct |
23 |
Correct |
27 ms |
5008 KB |
Output is correct |
24 |
Correct |
34 ms |
5436 KB |
Output is correct |
25 |
Correct |
114 ms |
9640 KB |
Output is correct |
26 |
Correct |
111 ms |
9648 KB |
Output is correct |
27 |
Correct |
111 ms |
9512 KB |
Output is correct |
28 |
Correct |
132 ms |
9480 KB |
Output is correct |
29 |
Correct |
108 ms |
9284 KB |
Output is correct |
30 |
Correct |
108 ms |
8864 KB |
Output is correct |
31 |
Correct |
73 ms |
8424 KB |
Output is correct |
32 |
Correct |
62 ms |
8476 KB |
Output is correct |
33 |
Correct |
11 ms |
1228 KB |
Output is correct |
34 |
Correct |
112 ms |
9632 KB |
Output is correct |
35 |
Correct |
119 ms |
9500 KB |
Output is correct |
36 |
Correct |
111 ms |
9668 KB |
Output is correct |
37 |
Correct |
111 ms |
9432 KB |
Output is correct |
38 |
Correct |
110 ms |
9504 KB |
Output is correct |
39 |
Correct |
109 ms |
9508 KB |
Output is correct |
40 |
Correct |
83 ms |
9444 KB |
Output is correct |
41 |
Correct |
34 ms |
5020 KB |
Output is correct |
42 |
Correct |
61 ms |
8472 KB |
Output is correct |
43 |
Correct |
88 ms |
9708 KB |
Output is correct |
44 |
Correct |
33 ms |
4932 KB |
Output is correct |
45 |
Correct |
70 ms |
9440 KB |
Output is correct |
46 |
Correct |
89 ms |
9752 KB |
Output is correct |
47 |
Correct |
90 ms |
9796 KB |
Output is correct |
48 |
Correct |
92 ms |
9780 KB |
Output is correct |