結果
問題 | No.2889 Rusk |
ユーザー | hiro1729 |
提出日時 | 2024-09-13 22:23:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 258 ms / 2,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 374 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 177,672 KB |
最終ジャッジ日時 | 2024-09-13 22:23:28 |
合計ジャッジ時間 | 9,105 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
51,840 KB |
testcase_01 | AC | 37 ms
52,608 KB |
testcase_02 | AC | 35 ms
52,096 KB |
testcase_03 | AC | 36 ms
52,096 KB |
testcase_04 | AC | 36 ms
52,480 KB |
testcase_05 | AC | 42 ms
52,608 KB |
testcase_06 | AC | 40 ms
52,864 KB |
testcase_07 | AC | 36 ms
52,480 KB |
testcase_08 | AC | 36 ms
52,480 KB |
testcase_09 | AC | 40 ms
52,608 KB |
testcase_10 | AC | 36 ms
52,352 KB |
testcase_11 | AC | 36 ms
51,968 KB |
testcase_12 | AC | 39 ms
52,352 KB |
testcase_13 | AC | 37 ms
52,608 KB |
testcase_14 | AC | 68 ms
76,544 KB |
testcase_15 | AC | 86 ms
87,296 KB |
testcase_16 | AC | 141 ms
117,568 KB |
testcase_17 | AC | 76 ms
82,176 KB |
testcase_18 | AC | 124 ms
106,792 KB |
testcase_19 | AC | 172 ms
133,156 KB |
testcase_20 | AC | 214 ms
157,904 KB |
testcase_21 | AC | 177 ms
133,560 KB |
testcase_22 | AC | 166 ms
142,472 KB |
testcase_23 | AC | 145 ms
120,004 KB |
testcase_24 | AC | 211 ms
154,424 KB |
testcase_25 | AC | 140 ms
119,808 KB |
testcase_26 | AC | 195 ms
131,300 KB |
testcase_27 | AC | 214 ms
164,388 KB |
testcase_28 | AC | 166 ms
127,768 KB |
testcase_29 | AC | 161 ms
132,612 KB |
testcase_30 | AC | 161 ms
132,488 KB |
testcase_31 | AC | 216 ms
163,772 KB |
testcase_32 | AC | 127 ms
108,056 KB |
testcase_33 | AC | 75 ms
79,892 KB |
testcase_34 | AC | 226 ms
167,888 KB |
testcase_35 | AC | 233 ms
168,088 KB |
testcase_36 | AC | 225 ms
167,892 KB |
testcase_37 | AC | 258 ms
167,512 KB |
testcase_38 | AC | 223 ms
167,944 KB |
testcase_39 | AC | 196 ms
165,392 KB |
testcase_40 | AC | 165 ms
139,448 KB |
testcase_41 | AC | 204 ms
177,672 KB |
testcase_42 | AC | 163 ms
138,468 KB |
testcase_43 | AC | 100 ms
96,640 KB |
testcase_44 | AC | 191 ms
163,716 KB |
testcase_45 | AC | 152 ms
135,904 KB |
testcase_46 | AC | 81 ms
87,808 KB |
testcase_47 | AC | 104 ms
99,268 KB |
testcase_48 | AC | 202 ms
162,440 KB |
testcase_49 | AC | 36 ms
52,096 KB |
testcase_50 | AC | 36 ms
52,096 KB |
testcase_51 | AC | 35 ms
52,096 KB |
testcase_52 | AC | 36 ms
52,096 KB |
testcase_53 | AC | 36 ms
52,096 KB |
testcase_54 | AC | 218 ms
169,472 KB |
ソースコード
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) D = [B[i] - A[i] for i in range(N)] E = [C[i] - B[i] for i in range(N)] ans = sum(A) P = [0] for i in D: P.append(P[-1] + i) Q = [0] for i in E: Q.append(Q[-1] + i) K = [0] M = 0 for i in range(1, N + 1): M = min(M, P[i]) K.append(min(K[-1], M + Q[i])) L = [0] * (N + 1) L[N] = P[N] + Q[N] M = P[N] for i in range(N - 1, -1, -1): M = max(M, P[i]) L[i] = max(L[i + 1], M + Q[i]) ans = max(ans, sum(A) + max(L[i + 1] - K[i] for i in range(N))) X = [0] M = 0 for i in range(1, N + 1): M = min(M, P[i]) X.append(max(X[-1], P[i] - M)) Y = [0] * (N + 1) Y[N] = 0 M = P[N] for i in range(N - 1, -1, -1): M = max(M, P[i]) Y[i] = max(Y[i + 1], M - P[i]) ans = max(ans, sum(A) + max(X[i] + Y[i + 1] for i in range(N))) ans = max(ans, sum(A) + max(X)) print(ans)