結果
問題 |
No.3077 Goodstuff Deck Builder(Hard)
|
ユーザー |
![]() |
提出日時 | 2025-03-28 23:29:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,353 ms / 3,000 ms |
コード長 | 459 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 223,368 KB |
最終ジャッジ日時 | 2025-03-28 23:29:59 |
合計ジャッジ時間 | 47,494 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 57 |
ソースコード
N,M=map(int,input().split()) dp=[0]*(M+1) np=[0]*(M+1) L=[] p=0 for i in range(N): c,d=map(int,input().split()) if c==0: p+=d else: L.append((c,d)) L.sort() N=len(L) result=0 for i in range(N): a,b=L[i][:] for x in range(a,M+1): np[x]=max(dp[x-a]+b,np[x]) for x in range(a): np[x]=max(np[x],dp[x]) w=max(np) result=max(result,w) for x in range(M+1): if x%2==0: dp[x]=np[x//2] else: dp[x]=0 print(result+p)