結果
問題 |
No.2982 Logic Battle
|
ユーザー |
![]() |
提出日時 | 2024-12-07 02:40:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 803 bytes |
コンパイル時間 | 322 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 85,548 KB |
最終ジャッジ日時 | 2024-12-07 02:41:44 |
合計ジャッジ時間 | 50,113 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 16 TLE * 11 |
ソースコード
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) > 70: heappop(q1) if len(q2) > 70: 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)