結果
問題 |
No.1858 Gorgeous Knapsack
|
ユーザー |
![]() |
提出日時 | 2022-02-27 20:08:07 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 368 bytes |
コンパイル時間 | 100 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 16,000 KB |
最終ジャッジ日時 | 2024-07-05 19:28:12 |
合計ジャッジ時間 | 8,682 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 TLE * 2 -- * 31 |
ソースコード
N,M = map(int, input().split()) VM = [list(map(int, input().split())) for _ in range(N)] DP = [0]*(M+1) VM = sorted(VM, reverse=True, key=lambda x: x[0]) ans = 0 for v,m in VM: for i in reversed(range(M)): if DP[i]>0 and i+m<=M and DP[i+m]<DP[i]+v: DP[i+m] = DP[i]+v if m<=M: DP[m]=max(DP[m],v) ans=max(ans,max(DP)*v) print(ans)