# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1048232 | 2024-08-08T05:44:19 Z | 8강딱? 크악 바로 LCK 정상화(#11094) | Bikeparking (EGOI24_bikeparking) | C++17 | 32 ms | 12124 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int A[300005]; int B[300005]; int C[300005]; int D[300005]; int E[300005]; signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int i, j; int N; cin >> N; for(i=1;i<=N;i++) cin >> A[i]; for(i=1;i<=N;i++) cin >> B[i]; for(i=1;i<=N;i++) { C[i] = A[i] + C[i-1]; D[i] = B[i] + D[i-1]; } int mi = C[N] - D[N]; for(i=N;i>=0;i--) { mi = min(mi, C[i-1] - D[i]); int lim = D[i] + mi; //cout << i << " : " << lim << '\n'; if(lim <= B[i]) { E[i] = lim; break; } else { E[i] = B[i]; } } int pt = 1; int ans = 0; for(i=1;i<=N;i++) { if(E[i]==0) continue; int v = E[i]; while(A[pt]==0) pt++; while(v) { if(v >= A[pt]) { ans += A[pt]; v -= A[pt]; A[pt] = 0; assert(pt < i); pt++; } else { ans += v; A[pt] -= v; v = 0; assert(pt < i); } } } pt = 0; for(i=N;i>=0;i--) { int v = B[i] - E[i]; if(v==0) continue; while(A[pt]==0) pt++; while(v) { if(v >= A[pt]) { ans += A[pt] * (pt < i ? 1 : (pt == i ? 0 : -1)); v -= A[pt]; A[pt] = 0; pt++; } else { ans += v * (pt < i ? 1 : (pt == i ? 0 : -1)); A[pt] -= v; v = 0; } } } /*for(i=1;i<=N;i++) cout << E[i] << ' '; cout << '\n';*/ cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 0 ms | 4444 KB | Output is correct |
5 | Correct | 0 ms | 4444 KB | Output is correct |
6 | Correct | 0 ms | 4444 KB | Output is correct |
7 | Correct | 0 ms | 4444 KB | Output is correct |
8 | Correct | 0 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 0 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 0 ms | 4444 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4440 KB | Output is correct |
16 | Correct | 0 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 0 ms | 4444 KB | Output is correct |
21 | Correct | 0 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 0 ms | 4444 KB | Output is correct |
5 | Correct | 17 ms | 9844 KB | Output is correct |
6 | Correct | 21 ms | 12120 KB | Output is correct |
7 | Correct | 32 ms | 12004 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 0 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4440 KB | Output is correct |
2 | Correct | 18 ms | 9688 KB | Output is correct |
3 | Correct | 18 ms | 12124 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Incorrect | 0 ms | 4444 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 0 ms | 4444 KB | Output is correct |
5 | Correct | 0 ms | 4444 KB | Output is correct |
6 | Correct | 0 ms | 4444 KB | Output is correct |
7 | Correct | 0 ms | 4444 KB | Output is correct |
8 | Correct | 0 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 0 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 0 ms | 4444 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4440 KB | Output is correct |
16 | Correct | 0 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 0 ms | 4444 KB | Output is correct |
21 | Correct | 0 ms | 4444 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 0 ms | 4444 KB | Output is correct |
25 | Correct | 0 ms | 4444 KB | Output is correct |
26 | Correct | 0 ms | 4444 KB | Output is correct |
27 | Correct | 0 ms | 4444 KB | Output is correct |
28 | Correct | 1 ms | 4524 KB | Output is correct |
29 | Correct | 0 ms | 4444 KB | Output is correct |
30 | Correct | 1 ms | 4444 KB | Output is correct |
31 | Correct | 0 ms | 4444 KB | Output is correct |
32 | Correct | 0 ms | 4444 KB | Output is correct |
33 | Correct | 0 ms | 4444 KB | Output is correct |
34 | Correct | 0 ms | 4444 KB | Output is correct |
35 | Correct | 0 ms | 4444 KB | Output is correct |
36 | Correct | 0 ms | 4444 KB | Output is correct |
37 | Correct | 1 ms | 4444 KB | Output is correct |
38 | Correct | 1 ms | 4444 KB | Output is correct |
39 | Correct | 1 ms | 4444 KB | Output is correct |
40 | Correct | 1 ms | 4444 KB | Output is correct |
41 | Correct | 1 ms | 4444 KB | Output is correct |
42 | Correct | 0 ms | 4444 KB | Output is correct |
43 | Correct | 0 ms | 4444 KB | Output is correct |
44 | Correct | 0 ms | 4444 KB | Output is correct |
45 | Incorrect | 1 ms | 4528 KB | Output isn't correct |
46 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 0 ms | 4444 KB | Output is correct |
3 | Correct | 0 ms | 4444 KB | Output is correct |
4 | Correct | 0 ms | 4444 KB | Output is correct |
5 | Correct | 0 ms | 4444 KB | Output is correct |
6 | Correct | 0 ms | 4444 KB | Output is correct |
7 | Correct | 0 ms | 4444 KB | Output is correct |
8 | Correct | 0 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 0 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 0 ms | 4444 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4440 KB | Output is correct |
16 | Correct | 0 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 0 ms | 4444 KB | Output is correct |
21 | Correct | 0 ms | 4444 KB | Output is correct |
22 | Correct | 0 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 0 ms | 4444 KB | Output is correct |
25 | Correct | 0 ms | 4444 KB | Output is correct |
26 | Correct | 17 ms | 9844 KB | Output is correct |
27 | Correct | 21 ms | 12120 KB | Output is correct |
28 | Correct | 32 ms | 12004 KB | Output is correct |
29 | Correct | 1 ms | 4440 KB | Output is correct |
30 | Correct | 1 ms | 4444 KB | Output is correct |
31 | Correct | 0 ms | 4444 KB | Output is correct |
32 | Correct | 0 ms | 4440 KB | Output is correct |
33 | Correct | 18 ms | 9688 KB | Output is correct |
34 | Correct | 18 ms | 12124 KB | Output is correct |
35 | Correct | 1 ms | 4440 KB | Output is correct |
36 | Incorrect | 0 ms | 4444 KB | Output isn't correct |
37 | Halted | 0 ms | 0 KB | - |