結果
| 問題 |
No.2982 Logic Battle
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-12-07 02:39:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 803 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 82,300 KB |
| 最終ジャッジ日時 | 2024-12-07 02:40:12 |
| 合計ジャッジ時間 | 32,913 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 26 |
ソースコード
from heapq import heappush, heappop
N = int(input())
cards = []
for _ in range(N):
A, B, C = map(int, input().split())
cards.append((A, B, C))
dp = [(-1, 0, 0)]
for i in range(N):
pp = []
dp, pp = pp, dp
q1 = []
q2 = []
for prev_j, x, tot in pp:
for j in range(3):
if prev_j == j: continue
nx = x + cards[i][j]
ntot = tot + nx
# dp.append((j, max(0, nx-1), ntot))
heappush(q1, (max(0, nx-1), ntot, j))
heappush(q2, (ntot, max(0, nx-1), j))
if len(q1) > 50: heappop(q1)
if len(q2) > 50: heappop(q2)
for nx, ntot, j in q1:
dp.append((j, nx, ntot))
for ntot, nx, j in q2:
dp.append((j, nx, ntot))
ans = max(tot for _, _, tot in dp)
print(ans)
norioc