# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1048243 | 2024-08-08T05:54:13 Z | 8강딱? 크악 바로 LCK 정상화(#11094) | Bikeparking (EGOI24_bikeparking) | C++17 | 26 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]; int sum = 0; for(i=N;i>=0;i--) { mi = min(mi, C[i-1] + sum); int lim = mi - sum; //cout << i << " : " << lim << '\n'; int val = min(lim, B[i]); E[i] = val; sum += val; } 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 = 1; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 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 | 1 ms | 4444 KB | Output is correct |
9 | Correct | 0 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 0 ms | 4444 KB | Output is correct |
20 | Correct | 0 ms | 4444 KB | Output is correct |
21 | Correct | 0 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4556 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 19 ms | 11988 KB | Output is correct |
6 | Correct | 19 ms | 12120 KB | Output is correct |
7 | Correct | 26 ms | 12124 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 18 ms | 11988 KB | Output is correct |
3 | Correct | 20 ms | 11996 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 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 | 1 ms | 4444 KB | Output is correct |
9 | Correct | 0 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 0 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 | 0 ms | 4444 KB | Output is correct |
24 | Correct | 0 ms | 4444 KB | Output is correct |
25 | Correct | 1 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 | 4444 KB | Output is correct |
29 | Correct | 0 ms | 4444 KB | Output is correct |
30 | Correct | 0 ms | 4444 KB | Output is correct |
31 | Correct | 1 ms | 4444 KB | Output is correct |
32 | Correct | 1 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 | 1 ms | 4444 KB | Output is correct |
36 | Correct | 0 ms | 4444 KB | Output is correct |
37 | Correct | 0 ms | 4444 KB | Output is correct |
38 | Correct | 0 ms | 4444 KB | Output is correct |
39 | Correct | 0 ms | 4444 KB | Output is correct |
40 | Correct | 0 ms | 4444 KB | Output is correct |
41 | Correct | 0 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 | 0 ms | 4444 KB | Output isn't correct |
46 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 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 | 1 ms | 4444 KB | Output is correct |
9 | Correct | 0 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 0 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 0 ms | 4444 KB | Output is correct |
15 | Correct | 0 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 0 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 0 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 | 1 ms | 4556 KB | Output is correct |
25 | Correct | 1 ms | 4440 KB | Output is correct |
26 | Correct | 19 ms | 11988 KB | Output is correct |
27 | Correct | 19 ms | 12120 KB | Output is correct |
28 | Correct | 26 ms | 12124 KB | Output is correct |
29 | Correct | 0 ms | 4444 KB | Output is correct |
30 | Correct | 1 ms | 4444 KB | Output is correct |
31 | Correct | 1 ms | 4444 KB | Output is correct |
32 | Correct | 1 ms | 4444 KB | Output is correct |
33 | Correct | 18 ms | 11988 KB | Output is correct |
34 | Correct | 20 ms | 11996 KB | Output is correct |
35 | Correct | 1 ms | 4444 KB | Output is correct |
36 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
37 | Halted | 0 ms | 0 KB | - |