結果
問題 | No.2889 Rusk |
ユーザー | norioc |
提出日時 | 2024-09-14 14:28:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 698 ms / 2,000 ms |
コード長 | 1,517 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 82,192 KB |
実行使用メモリ | 142,528 KB |
最終ジャッジ日時 | 2024-09-14 14:28:49 |
合計ジャッジ時間 | 21,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,888 KB |
testcase_01 | AC | 42 ms
53,412 KB |
testcase_02 | AC | 43 ms
53,248 KB |
testcase_03 | AC | 43 ms
53,504 KB |
testcase_04 | AC | 54 ms
62,080 KB |
testcase_05 | AC | 42 ms
53,504 KB |
testcase_06 | AC | 58 ms
63,488 KB |
testcase_07 | AC | 43 ms
53,248 KB |
testcase_08 | AC | 54 ms
62,080 KB |
testcase_09 | AC | 56 ms
63,488 KB |
testcase_10 | AC | 45 ms
53,212 KB |
testcase_11 | AC | 44 ms
53,760 KB |
testcase_12 | AC | 57 ms
63,616 KB |
testcase_13 | AC | 54 ms
62,336 KB |
testcase_14 | AC | 147 ms
78,484 KB |
testcase_15 | AC | 220 ms
87,156 KB |
testcase_16 | AC | 385 ms
112,012 KB |
testcase_17 | AC | 210 ms
83,328 KB |
testcase_18 | AC | 360 ms
97,704 KB |
testcase_19 | AC | 512 ms
124,808 KB |
testcase_20 | AC | 599 ms
125,608 KB |
testcase_21 | AC | 527 ms
124,000 KB |
testcase_22 | AC | 468 ms
123,280 KB |
testcase_23 | AC | 437 ms
111,872 KB |
testcase_24 | AC | 603 ms
122,832 KB |
testcase_25 | AC | 411 ms
111,604 KB |
testcase_26 | AC | 520 ms
124,672 KB |
testcase_27 | AC | 608 ms
126,360 KB |
testcase_28 | AC | 438 ms
116,484 KB |
testcase_29 | AC | 437 ms
119,832 KB |
testcase_30 | AC | 439 ms
120,128 KB |
testcase_31 | AC | 606 ms
126,372 KB |
testcase_32 | AC | 353 ms
106,464 KB |
testcase_33 | AC | 196 ms
81,536 KB |
testcase_34 | AC | 698 ms
134,652 KB |
testcase_35 | AC | 667 ms
134,568 KB |
testcase_36 | AC | 681 ms
134,272 KB |
testcase_37 | AC | 680 ms
134,320 KB |
testcase_38 | AC | 671 ms
134,392 KB |
testcase_39 | AC | 617 ms
136,028 KB |
testcase_40 | AC | 523 ms
123,640 KB |
testcase_41 | AC | 634 ms
142,528 KB |
testcase_42 | AC | 499 ms
112,896 KB |
testcase_43 | AC | 295 ms
96,000 KB |
testcase_44 | AC | 589 ms
135,292 KB |
testcase_45 | AC | 473 ms
108,416 KB |
testcase_46 | AC | 233 ms
87,040 KB |
testcase_47 | AC | 317 ms
96,640 KB |
testcase_48 | AC | 560 ms
128,332 KB |
testcase_49 | AC | 44 ms
52,864 KB |
testcase_50 | AC | 44 ms
53,120 KB |
testcase_51 | AC | 44 ms
52,864 KB |
testcase_52 | AC | 45 ms
53,120 KB |
testcase_53 | AC | 45 ms
53,248 KB |
testcase_54 | AC | 676 ms
135,724 KB |
ソースコード
from enum import IntEnum, auto # ステート遷移 class E(IntEnum): S = 0 # 開始 Nothing1 = auto() Nothing2 = auto() Nothing3 = auto() Single1 = auto() Single2 = auto() Both = auto() def nexts(self): match self: case E.S: return [E.Nothing1, E.Single1, E.Both] case E.Nothing1: return [E.Nothing1, E.Single1, E.Both] case E.Nothing2: return [E.Nothing2, E.Single2] case E.Nothing3: return [E.Nothing3] case E.Single1: return [E.Single1, E.Both, E.Nothing2] case E.Single2: return [E.Single2, E.Nothing3] case E.Both: return [E.Both, E.Single2, E.Nothing3] assert False def cost(self, a, b, c): match self: case E.S: return 0 case E.Nothing1 | E.Nothing2 | E.Nothing3: return a case E.Single1 | E.Single2: return b case E.Both: return c assert False @staticmethod def states(): for fm in E: for to in fm.nexts(): yield fm, to N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) dp = [[0] * len(E) for _ in range(N+1)] for i, (a, b, c) in enumerate(zip(A, B, C)): for fm, to in E.states(): dp[i+1][to] = max(dp[i+1][to], dp[i][fm] + to.cost(a, b, c)) end_states = [E.Single1, E.Single2, E.Both, E.Nothing3] ans = max(dp[N][s] for s in end_states) print(ans)