# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
508927 |
2022-01-14T01:34:45 Z |
ITO |
Snowball (JOI21_ho_t2) |
C++11 |
|
238 ms |
13916 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lr[200001][2];
priority_queue<pair<ll, ll>> pq;
int main() {
int n, q;
ll x, xt, w, cu = 0, ml = 0, mr = 0;
cin >> n >> q;
cin >> xt;
for (int i = 1; i < n; i++) {
cin >> x;
pq.push(make_pair(xt - x, i));
xt = x;
}
for (int i = 0; i < q; i++) {
cin >> w;
cu += w;
if (cu < ml) {
ml = cu;
while (!pq.empty() && -pq.top().first <= mr - ml) {
lr[pq.top().second][0] = -pq.top().first - mr;
lr[pq.top().second - 1][1] = mr;
pq.pop();
}
}
if (cu > mr) {
mr = cu;
while (!pq.empty() && -pq.top().first < mr - ml) {
lr[pq.top().second][0] = -ml;
lr[pq.top().second - 1][1] = ml - pq.top().first;
pq.pop();
}
}
}
while (!pq.empty()) {
lr[pq.top().second][0] = -ml;
lr[pq.top().second - 1][1] = mr;
pq.pop();
}
lr[0][0] = -ml;
lr[n - 1][1] = mr;
for (int i = 0; i < n; i++) {
cout << lr[i][0] + lr[i][1] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
436 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
308 KB |
Output is correct |
10 |
Correct |
2 ms |
312 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
312 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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
436 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
308 KB |
Output is correct |
10 |
Correct |
2 ms |
312 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
332 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
78 ms |
2320 KB |
Output is correct |
21 |
Correct |
74 ms |
2116 KB |
Output is correct |
22 |
Correct |
66 ms |
1988 KB |
Output is correct |
23 |
Correct |
63 ms |
1900 KB |
Output is correct |
24 |
Correct |
72 ms |
2824 KB |
Output is correct |
25 |
Correct |
200 ms |
12008 KB |
Output is correct |
26 |
Correct |
190 ms |
11808 KB |
Output is correct |
27 |
Correct |
185 ms |
11524 KB |
Output is correct |
28 |
Correct |
192 ms |
11688 KB |
Output is correct |
29 |
Correct |
185 ms |
11232 KB |
Output is correct |
30 |
Correct |
173 ms |
10536 KB |
Output is correct |
31 |
Correct |
157 ms |
10024 KB |
Output is correct |
32 |
Correct |
157 ms |
10120 KB |
Output is correct |
33 |
Correct |
20 ms |
1572 KB |
Output is correct |
34 |
Correct |
200 ms |
12308 KB |
Output is correct |
35 |
Correct |
191 ms |
11696 KB |
Output is correct |
36 |
Correct |
196 ms |
11904 KB |
Output is correct |
37 |
Correct |
188 ms |
11852 KB |
Output is correct |
38 |
Correct |
192 ms |
11520 KB |
Output is correct |
39 |
Correct |
186 ms |
11740 KB |
Output is correct |
40 |
Correct |
183 ms |
11760 KB |
Output is correct |
41 |
Correct |
99 ms |
3076 KB |
Output is correct |
42 |
Correct |
162 ms |
10152 KB |
Output is correct |
43 |
Correct |
225 ms |
13460 KB |
Output is correct |
44 |
Correct |
95 ms |
2824 KB |
Output is correct |
45 |
Correct |
187 ms |
11760 KB |
Output is correct |
46 |
Correct |
219 ms |
13608 KB |
Output is correct |
47 |
Correct |
226 ms |
13864 KB |
Output is correct |
48 |
Correct |
238 ms |
13916 KB |
Output is correct |