# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
533884 | 2022-03-07T14:40:12 Z | jmyszka2007 | Snowball (JOI21_ho_t2) | C++17 | 162 ms | 12784 KB |
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 2 * 1e5; typedef long long ll; ll s[MAXN + 10]; ll mx[MAXN + 10]; ll mn[MAXN + 10]; ll tab[MAXN + 10]; ll w[MAXN + 10]; ll res[MAXN + 10]; int bs(int l, int r, ll x) { while(l < r) { int mid = (l + r + 1) / 2; if((mx[mid] - mn[mid]) <= x) { l = mid; } else { r = mid - 1; } } return l; } int main() { int n, t; scanf("%d%d", &n, &t); for(int i = 1; i <= n; i++) { scanf("%lld", &tab[i]); } for(int i = 1; i <= t; i++) { scanf("%lld", &w[i]); s[i] = s[i - 1] + w[i]; mx[i] = max(mx[i - 1], s[i]); mn[i] = min(mn[i - 1], s[i]); } for(int i = 1; i < n; i++) { ll d = tab[i + 1] - tab[i]; int m = bs(0, t, d); res[i] += mx[m]; res[i + 1] += mn[m] * -1; if(m == t) { continue; } if(w[m + 1] >= 0) { res[i] += (d - mx[m] + mn[m]); } else { res[i + 1] += (d - mx[m] + mn[m]); } } res[1] += mn[t] * -1; res[n] += mx[t]; for(int i = 1; i <= n; i++) { printf("%lld ", res[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 460 KB | Output is correct |
5 | Correct | 2 ms | 460 KB | Output is correct |
6 | Correct | 2 ms | 460 KB | Output is correct |
7 | Correct | 2 ms | 460 KB | Output is correct |
8 | Correct | 2 ms | 460 KB | Output is correct |
9 | Correct | 2 ms | 460 KB | Output is correct |
10 | Correct | 2 ms | 444 KB | Output is correct |
11 | Correct | 1 ms | 460 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 | 332 KB | Output is correct |
15 | Correct | 2 ms | 436 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 1 ms | 460 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 440 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 460 KB | Output is correct |
5 | Correct | 2 ms | 460 KB | Output is correct |
6 | Correct | 2 ms | 460 KB | Output is correct |
7 | Correct | 2 ms | 460 KB | Output is correct |
8 | Correct | 2 ms | 460 KB | Output is correct |
9 | Correct | 2 ms | 460 KB | Output is correct |
10 | Correct | 2 ms | 444 KB | Output is correct |
11 | Correct | 1 ms | 460 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 | 332 KB | Output is correct |
15 | Correct | 2 ms | 436 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 1 ms | 460 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 440 KB | Output is correct |
20 | Correct | 32 ms | 7708 KB | Output is correct |
21 | Correct | 47 ms | 7804 KB | Output is correct |
22 | Correct | 32 ms | 7800 KB | Output is correct |
23 | Correct | 35 ms | 7868 KB | Output is correct |
24 | Correct | 48 ms | 8324 KB | Output is correct |
25 | Correct | 162 ms | 12480 KB | Output is correct |
26 | Correct | 153 ms | 12544 KB | Output is correct |
27 | Correct | 139 ms | 12332 KB | Output is correct |
28 | Correct | 129 ms | 12304 KB | Output is correct |
29 | Correct | 107 ms | 12060 KB | Output is correct |
30 | Correct | 126 ms | 11684 KB | Output is correct |
31 | Correct | 99 ms | 11288 KB | Output is correct |
32 | Correct | 70 ms | 11244 KB | Output is correct |
33 | Correct | 11 ms | 1736 KB | Output is correct |
34 | Correct | 134 ms | 12452 KB | Output is correct |
35 | Correct | 117 ms | 12228 KB | Output is correct |
36 | Correct | 137 ms | 12536 KB | Output is correct |
37 | Correct | 115 ms | 12304 KB | Output is correct |
38 | Correct | 115 ms | 12316 KB | Output is correct |
39 | Correct | 126 ms | 12516 KB | Output is correct |
40 | Correct | 89 ms | 12260 KB | Output is correct |
41 | Correct | 46 ms | 7800 KB | Output is correct |
42 | Correct | 78 ms | 11304 KB | Output is correct |
43 | Correct | 106 ms | 12540 KB | Output is correct |
44 | Correct | 37 ms | 7816 KB | Output is correct |
45 | Correct | 85 ms | 12276 KB | Output is correct |
46 | Correct | 93 ms | 12600 KB | Output is correct |
47 | Correct | 126 ms | 12596 KB | Output is correct |
48 | Correct | 111 ms | 12784 KB | Output is correct |