# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
937882 |
2024-03-04T15:55:39 Z |
zwezdinv |
Snowball (JOI21_ho_t2) |
C++17 |
|
66 ms |
15300 KB |
#include <bits/stdc++.h>
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int n, q;
std::cin >> n >> q;
std::vector<long long> a(n);
for (auto& i : a) std::cin >> i;
std::vector<std::pair<long long, int>> b;
for (int i = 0; i < n - 1; ++i) {
b.emplace_back(a[i + 1] - a[i], i);
}
std::sort(b.begin(), b.end());
std::vector<long long> lb(n, -1e18), rb(n, 1e18);
std::pair<long long, long long> seg = {0, 0};
long long cur = 0;
for (int i = 0, j = 0; i < q; ++i) {
auto nw = seg;
long long x;
std::cin >> x;
cur += x;
nw.first = std::min(nw.first, cur);
nw.second = std::max(nw.second, cur);
while (j < b.size() && b[j].first <= nw.second - nw.first) {
int k = b[j].second;
if (cur > 0) {
rb[k] = a[k + 1] + seg.first;
lb[k + 1] = rb[k];
} else {
lb[k + 1] = a[k] + seg.second;
rb[k] = lb[k + 1];
}
j++;
}
seg = nw;
}
for (int i = 0; i < n; ++i) {
lb[i] = std::max(lb[i], a[i] + seg.first);
rb[i] = std::min(rb[i], a[i] + seg.second);
std::cout << rb[i] - lb[i] << '\n';
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | while (j < b.size() && b[j].first <= nw.second - nw.first) {
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
464 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 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 |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
464 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
19 ms |
2396 KB |
Output is correct |
21 |
Correct |
18 ms |
2232 KB |
Output is correct |
22 |
Correct |
17 ms |
2136 KB |
Output is correct |
23 |
Correct |
16 ms |
2056 KB |
Output is correct |
24 |
Correct |
19 ms |
3028 KB |
Output is correct |
25 |
Correct |
61 ms |
13504 KB |
Output is correct |
26 |
Correct |
63 ms |
14280 KB |
Output is correct |
27 |
Correct |
64 ms |
13216 KB |
Output is correct |
28 |
Correct |
61 ms |
13256 KB |
Output is correct |
29 |
Correct |
62 ms |
13248 KB |
Output is correct |
30 |
Correct |
59 ms |
12828 KB |
Output is correct |
31 |
Correct |
63 ms |
11536 KB |
Output is correct |
32 |
Correct |
44 ms |
11968 KB |
Output is correct |
33 |
Correct |
7 ms |
1756 KB |
Output is correct |
34 |
Correct |
61 ms |
13772 KB |
Output is correct |
35 |
Correct |
65 ms |
13244 KB |
Output is correct |
36 |
Correct |
61 ms |
13512 KB |
Output is correct |
37 |
Correct |
60 ms |
13216 KB |
Output is correct |
38 |
Correct |
63 ms |
13088 KB |
Output is correct |
39 |
Correct |
64 ms |
14360 KB |
Output is correct |
40 |
Correct |
66 ms |
14208 KB |
Output is correct |
41 |
Correct |
19 ms |
3152 KB |
Output is correct |
42 |
Correct |
53 ms |
11588 KB |
Output is correct |
43 |
Correct |
53 ms |
15036 KB |
Output is correct |
44 |
Correct |
22 ms |
2896 KB |
Output is correct |
45 |
Correct |
60 ms |
13760 KB |
Output is correct |
46 |
Correct |
57 ms |
15292 KB |
Output is correct |
47 |
Correct |
59 ms |
15288 KB |
Output is correct |
48 |
Correct |
58 ms |
15300 KB |
Output is correct |