結果
問題 | No.2889 Rusk |
ユーザー | norioc |
提出日時 | 2024-09-14 02:04:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 711 ms / 2,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 82,476 KB |
実行使用メモリ | 142,464 KB |
最終ジャッジ日時 | 2024-09-14 02:05:11 |
合計ジャッジ時間 | 21,787 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,912 KB |
testcase_01 | AC | 41 ms
53,540 KB |
testcase_02 | AC | 41 ms
53,380 KB |
testcase_03 | AC | 41 ms
54,052 KB |
testcase_04 | AC | 63 ms
66,896 KB |
testcase_05 | AC | 41 ms
53,724 KB |
testcase_06 | AC | 69 ms
69,040 KB |
testcase_07 | AC | 45 ms
54,208 KB |
testcase_08 | AC | 64 ms
67,036 KB |
testcase_09 | AC | 65 ms
67,628 KB |
testcase_10 | AC | 42 ms
54,212 KB |
testcase_11 | AC | 44 ms
54,592 KB |
testcase_12 | AC | 68 ms
68,212 KB |
testcase_13 | AC | 63 ms
66,540 KB |
testcase_14 | AC | 153 ms
78,344 KB |
testcase_15 | AC | 218 ms
87,712 KB |
testcase_16 | AC | 383 ms
111,804 KB |
testcase_17 | AC | 194 ms
83,652 KB |
testcase_18 | AC | 330 ms
97,576 KB |
testcase_19 | AC | 513 ms
124,884 KB |
testcase_20 | AC | 590 ms
125,304 KB |
testcase_21 | AC | 520 ms
124,072 KB |
testcase_22 | AC | 468 ms
123,308 KB |
testcase_23 | AC | 395 ms
111,764 KB |
testcase_24 | AC | 607 ms
123,040 KB |
testcase_25 | AC | 391 ms
111,748 KB |
testcase_26 | AC | 533 ms
125,012 KB |
testcase_27 | AC | 601 ms
126,316 KB |
testcase_28 | AC | 411 ms
116,152 KB |
testcase_29 | AC | 441 ms
119,800 KB |
testcase_30 | AC | 435 ms
119,952 KB |
testcase_31 | AC | 654 ms
126,296 KB |
testcase_32 | AC | 347 ms
107,056 KB |
testcase_33 | AC | 186 ms
81,584 KB |
testcase_34 | AC | 693 ms
134,288 KB |
testcase_35 | AC | 674 ms
134,344 KB |
testcase_36 | AC | 711 ms
134,284 KB |
testcase_37 | AC | 689 ms
134,268 KB |
testcase_38 | AC | 686 ms
134,268 KB |
testcase_39 | AC | 610 ms
136,472 KB |
testcase_40 | AC | 514 ms
123,480 KB |
testcase_41 | AC | 636 ms
142,464 KB |
testcase_42 | AC | 488 ms
112,648 KB |
testcase_43 | AC | 295 ms
96,036 KB |
testcase_44 | AC | 591 ms
135,744 KB |
testcase_45 | AC | 482 ms
108,256 KB |
testcase_46 | AC | 227 ms
87,020 KB |
testcase_47 | AC | 310 ms
96,784 KB |
testcase_48 | AC | 537 ms
128,384 KB |
testcase_49 | AC | 43 ms
54,600 KB |
testcase_50 | AC | 42 ms
55,020 KB |
testcase_51 | AC | 42 ms
54,332 KB |
testcase_52 | AC | 41 ms
54,004 KB |
testcase_53 | AC | 42 ms
53,544 KB |
testcase_54 | AC | 660 ms
135,344 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, E.Nothing3] case E.Nothing1: return [E.Nothing1, E.Single1, E.Both, E.Nothing3] case E.Nothing2: return [E.Nothing2, E.Single2] case E.Nothing3: return [E.Nothing3] case E.Single1: return [E.Single1, E.Both, E.Nothing2, E.Nothing3] 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 in range(N): a, b, c = A[i], B[i], C[i] for fm, to in E.states(): dp[i+1][to] = max(dp[i+1][to], dp[i][fm] + to.cost(a, b, c)) ends = [E.Single1, E.Single2, E.Both, E.Nothing3] ans = max(dp[N][s] for s in ends) print(ans)