# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
807715 | 2023-08-04T22:40:52 Z | dong_liu | Snowball (JOI21_ho_t2) | C++17 | 108 ms | 12204 KB |
#include <iostream> using namespace std; const int N = 2e5, Q = 2e5; int main() { int n, q; scanf("%d%d", &n, &q); static long long x[N]; for (int i = 0; i < n; i++) scanf("%lld", &x[i]); static long long mn[Q + 1], mx[Q + 1]; long long c = 0; for (int i = 0; i < q; i++) { long long d; scanf("%lld", &d); c += d; mn[i + 1] = min(mn[i], c), mx[i + 1] = max(mx[i], c); } long long l = x[0] + mn[q]; for (int i = 0; i < n - 1; i++) { int low = 1, hi = q; while (low < hi) { int t = (low + hi) / 2; if (x[i] + mx[t] >= x[i + 1] + mn[t]) hi = t; else low = t + 1; } long long r = mn[low] == mn[low - 1] ? x[i + 1] + mn[low] : x[i] + mx[low]; printf("%lld\n", min(x[i] + mx[q], r) - max(l, x[i] + mn[q])); l = r; } printf("%lld\n", x[n - 1] + mx[q] - max(l, x[n - 1] + mn[q])); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 320 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 2 ms | 360 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 320 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 2 ms | 360 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 328 KB | Output is correct |
20 | Correct | 21 ms | 5460 KB | Output is correct |
21 | Correct | 20 ms | 5312 KB | Output is correct |
22 | Correct | 19 ms | 5160 KB | Output is correct |
23 | Correct | 21 ms | 5048 KB | Output is correct |
24 | Correct | 24 ms | 5312 KB | Output is correct |
25 | Correct | 86 ms | 10216 KB | Output is correct |
26 | Correct | 86 ms | 10136 KB | Output is correct |
27 | Correct | 84 ms | 9804 KB | Output is correct |
28 | Correct | 108 ms | 9988 KB | Output is correct |
29 | Correct | 84 ms | 9560 KB | Output is correct |
30 | Correct | 79 ms | 8892 KB | Output is correct |
31 | Correct | 58 ms | 8268 KB | Output is correct |
32 | Correct | 52 ms | 8524 KB | Output is correct |
33 | Correct | 8 ms | 1392 KB | Output is correct |
34 | Correct | 86 ms | 10620 KB | Output is correct |
35 | Correct | 87 ms | 9976 KB | Output is correct |
36 | Correct | 100 ms | 10256 KB | Output is correct |
37 | Correct | 86 ms | 9944 KB | Output is correct |
38 | Correct | 86 ms | 9800 KB | Output is correct |
39 | Correct | 95 ms | 10044 KB | Output is correct |
40 | Correct | 61 ms | 10032 KB | Output is correct |
41 | Correct | 23 ms | 6092 KB | Output is correct |
42 | Correct | 52 ms | 8480 KB | Output is correct |
43 | Correct | 74 ms | 11956 KB | Output is correct |
44 | Correct | 21 ms | 5992 KB | Output is correct |
45 | Correct | 58 ms | 9984 KB | Output is correct |
46 | Correct | 64 ms | 11912 KB | Output is correct |
47 | Correct | 64 ms | 12128 KB | Output is correct |
48 | Correct | 68 ms | 12204 KB | Output is correct |