# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1005602 |
2024-06-22T16:02:50 Z |
vjudge1 |
Snowball (JOI21_ho_t2) |
C++17 |
|
205 ms |
17080 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int n, q;
cin >> n >> q;
vector<int> x(n), l(n), r(n);
vector<int> mi(q+1), ma(q+1);
for(auto &i: x) cin >> i;
vector<int> op(q+1);
for(int i = 1; i <= q; i++){
cin >> op[i];
}
for(int i = 1; i <= q; i++){
op[i] += op[i - 1];
mi[i] = mi[i - 1];
ma[i] = ma[i - 1];
if(op[i] < op[mi[i]]) mi[i] = i;
if(op[i] > op[ma[i]]) ma[i] = i;
}
l[0] = x[0] + op[mi[q]];
r[n - 1] = x[n - 1] + op[ma[q]];
for(int i = 0; i < n - 1; i++){
int s = -1;
for(int l = 20; l >= 0; l--){
int tmp = s+(1 << l);
if(tmp >= q) continue;
if((x[i] + op[ma[tmp]] >= x[i + 1] + op[mi[tmp]])) continue;
s = tmp;
}
s++;
if(x[i] + op[ma[s]] >= x[i + 1] + op[mi[s]]){
if(ma[s] < mi[s]){
r[i] = x[i] + op[ma[s]];
l[i+1] = r[i];
}
else{
l[i + 1] = x[i + 1] + op[mi[s]];
r[i] = l[i + 1];
}
}
else{
r[i] = min(x[i + 1] + op[mi[s]], x[i] + op[ma[s]]);
l[i + 1] = max(x[i + 1] + op[mi[s]], x[i] + op[ma[s]]);
}
}
for(int i = 0; i < n; i++) cout << r[i] - l[i] << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
452 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
540 KB |
Output is correct |
11 |
Correct |
2 ms |
540 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
552 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
564 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
452 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
540 KB |
Output is correct |
11 |
Correct |
2 ms |
540 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
552 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
564 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
57 ms |
7252 KB |
Output is correct |
21 |
Correct |
52 ms |
6996 KB |
Output is correct |
22 |
Correct |
48 ms |
6872 KB |
Output is correct |
23 |
Correct |
48 ms |
6544 KB |
Output is correct |
24 |
Correct |
56 ms |
7248 KB |
Output is correct |
25 |
Correct |
181 ms |
15036 KB |
Output is correct |
26 |
Correct |
174 ms |
14916 KB |
Output is correct |
27 |
Correct |
179 ms |
14676 KB |
Output is correct |
28 |
Correct |
205 ms |
14796 KB |
Output is correct |
29 |
Correct |
167 ms |
14172 KB |
Output is correct |
30 |
Correct |
145 ms |
13648 KB |
Output is correct |
31 |
Correct |
109 ms |
13140 KB |
Output is correct |
32 |
Correct |
118 ms |
13136 KB |
Output is correct |
33 |
Correct |
15 ms |
1884 KB |
Output is correct |
34 |
Correct |
174 ms |
15444 KB |
Output is correct |
35 |
Correct |
161 ms |
14916 KB |
Output is correct |
36 |
Correct |
174 ms |
14928 KB |
Output is correct |
37 |
Correct |
168 ms |
14672 KB |
Output is correct |
38 |
Correct |
177 ms |
14672 KB |
Output is correct |
39 |
Correct |
168 ms |
14928 KB |
Output is correct |
40 |
Correct |
137 ms |
14784 KB |
Output is correct |
41 |
Correct |
64 ms |
7760 KB |
Output is correct |
42 |
Correct |
99 ms |
13116 KB |
Output is correct |
43 |
Correct |
164 ms |
16572 KB |
Output is correct |
44 |
Correct |
71 ms |
7676 KB |
Output is correct |
45 |
Correct |
119 ms |
14664 KB |
Output is correct |
46 |
Correct |
166 ms |
16720 KB |
Output is correct |
47 |
Correct |
162 ms |
16976 KB |
Output is correct |
48 |
Correct |
171 ms |
17080 KB |
Output is correct |