# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
568685 | 2022-05-26T04:58:58 Z | dantoh000 | Snowball (JOI21_ho_t2) | C++14 | 118 ms | 16844 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int n,q; int p[200005]; int D[200005]; int l[200005]; int r[200005]; int pos[200005]; int ans[200005]; main(){ scanf("%lld%lld",&n,&q); for (int i = 1; i <= n; i++){ scanf("%lld",&p[i]); } int cur = 0; l[0] = r[0] = D[0] = 0; for (int i = 1, x; i <= q+1; i++){ if (i == q+1) x = 0; else scanf("%lld",&x); cur += x; l[i] = min(l[i-1], cur); r[i] = max(r[i-1], cur); D[i] = r[i]-l[i]; pos[i] = cur; } ans[1] += -l[q]; ans[n] += r[q]; for (int i = 1; i < n; i++){ int d = p[i+1]-p[i]; int id = lower_bound(D, D+q+1, d) - D; int L = -l[id]; int R = r[id]; L = min(L, d); R = min(R, d); if (pos[id] == l[id]) L = min(L, d - R); else if (pos[id] == r[id]) R = min(R, d - L); ///printf("position %d moves %d left, position %d moves %d right\n",i+1,L,i,R); ans[i] += R; ans[i+1] += L; } for (int i = 1; i <= n; i++){ printf("%lld\n",ans[i]); } }
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 | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 416 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 1 ms | 308 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 452 KB | Output is correct |
16 | Correct | 2 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 444 KB | Output is correct |
18 | Correct | 0 ms | 304 KB | Output is correct |
19 | Correct | 1 ms | 468 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 | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 416 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 380 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 1 ms | 308 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 452 KB | Output is correct |
16 | Correct | 2 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 444 KB | Output is correct |
18 | Correct | 0 ms | 304 KB | Output is correct |
19 | Correct | 1 ms | 468 KB | Output is correct |
20 | Correct | 32 ms | 8652 KB | Output is correct |
21 | Correct | 27 ms | 8428 KB | Output is correct |
22 | Correct | 26 ms | 8320 KB | Output is correct |
23 | Correct | 36 ms | 8184 KB | Output is correct |
24 | Correct | 36 ms | 8616 KB | Output is correct |
25 | Correct | 109 ms | 14904 KB | Output is correct |
26 | Correct | 107 ms | 14924 KB | Output is correct |
27 | Correct | 101 ms | 14588 KB | Output is correct |
28 | Correct | 101 ms | 14764 KB | Output is correct |
29 | Correct | 118 ms | 14208 KB | Output is correct |
30 | Correct | 91 ms | 13632 KB | Output is correct |
31 | Correct | 83 ms | 13044 KB | Output is correct |
32 | Correct | 63 ms | 13204 KB | Output is correct |
33 | Correct | 10 ms | 1848 KB | Output is correct |
34 | Correct | 111 ms | 15344 KB | Output is correct |
35 | Correct | 106 ms | 14680 KB | Output is correct |
36 | Correct | 118 ms | 14888 KB | Output is correct |
37 | Correct | 111 ms | 14648 KB | Output is correct |
38 | Correct | 109 ms | 14500 KB | Output is correct |
39 | Correct | 109 ms | 14796 KB | Output is correct |
40 | Correct | 74 ms | 14704 KB | Output is correct |
41 | Correct | 33 ms | 9236 KB | Output is correct |
42 | Correct | 73 ms | 13096 KB | Output is correct |
43 | Correct | 81 ms | 16432 KB | Output is correct |
44 | Correct | 44 ms | 9152 KB | Output is correct |
45 | Correct | 76 ms | 14636 KB | Output is correct |
46 | Correct | 80 ms | 16588 KB | Output is correct |
47 | Correct | 83 ms | 16844 KB | Output is correct |
48 | Correct | 82 ms | 16832 KB | Output is correct |