結果

問題 No.1858 Gorgeous Knapsack
ユーザー pluto77
提出日時 2022-03-04 10:22:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,140 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2024-07-18 07:38:07
合計ジャッジ時間 4,393 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1858
n,m=map(int,input().split())
l=[]
for i in range(n):
 l.append(list(map(int,input().split())))
l.sort(key=lambda x:x[0],reverse=True)
res=0
dp=[0]*(m+1)
for v,w in l:
 for i in range(m-w,-1,-1):
  dp[i+w]=max(dp[i+w],dp[i]+v)
 res=max(res,v*dp[m])
print(res)
0