結果
| 問題 | No.45 回転寿司 |
| ユーザー |
norioc
|
| 提出日時 | 2024-07-15 10:10:51 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 115 ms / 5,000 ms |
| + 981µs | |
| コード長 | 677 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 95,916 KB |
| 実行使用メモリ | 86,656 KB |
| 最終ジャッジ日時 | 2026-08-13 05:41:01 |
| 合計ジャッジ時間 | 5,995 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
from enum import IntEnum, auto
# ステート遷移
class E(IntEnum):
EAT = 0
NOT_EAT = auto()
def nexts(self):
match self:
case E.EAT: return [E.NOT_EAT]
case E.NOT_EAT: return [E.EAT, E.NOT_EAT]
assert False
def cost(self, x: int) -> int:
match self:
case E.EAT: return x
case E.NOT_EAT: return 0
assert False
N = int(input())
V = list(map(int, input().split()))
dp = [[0] * len(E) for _ in range(N+1)]
for i, v in enumerate(V):
for fm in E:
for to in fm.nexts():
dp[i+1][to] = max(dp[i+1][to], dp[i][fm] + to.cost(v))
ans = max(dp[N])
print(ans)
norioc