結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 KazunKazun
提出日時 2022-03-03 18:54:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 311 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 86,728 KB
実行使用メモリ 78,180 KB
最終ジャッジ日時 2023-09-24 14:36:06
合計ジャッジ時間 8,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,192 KB
testcase_01 AC 72 ms
71,292 KB
testcase_02 AC 73 ms
71,272 KB
testcase_03 AC 83 ms
75,776 KB
testcase_04 AC 146 ms
77,596 KB
testcase_05 AC 97 ms
76,304 KB
testcase_06 AC 145 ms
77,896 KB
testcase_07 AC 124 ms
77,920 KB
testcase_08 AC 167 ms
78,020 KB
testcase_09 AC 205 ms
77,884 KB
testcase_10 AC 133 ms
78,180 KB
testcase_11 AC 128 ms
77,696 KB
testcase_12 AC 181 ms
77,740 KB
testcase_13 AC 109 ms
77,860 KB
testcase_14 AC 77 ms
76,148 KB
testcase_15 AC 73 ms
71,568 KB
testcase_16 AC 76 ms
76,112 KB
testcase_17 AC 72 ms
71,524 KB
testcase_18 AC 72 ms
71,232 KB
testcase_19 AC 72 ms
71,464 KB
testcase_20 AC 71 ms
71,440 KB
testcase_21 AC 72 ms
71,560 KB
testcase_22 AC 71 ms
71,292 KB
testcase_23 AC 71 ms
71,152 KB
testcase_24 AC 94 ms
76,188 KB
testcase_25 AC 141 ms
77,840 KB
testcase_26 AC 152 ms
77,772 KB
testcase_27 AC 148 ms
77,580 KB
testcase_28 AC 120 ms
77,936 KB
testcase_29 AC 101 ms
77,428 KB
testcase_30 AC 106 ms
77,724 KB
testcase_31 AC 106 ms
77,668 KB
testcase_32 AC 106 ms
77,972 KB
testcase_33 AC 106 ms
77,692 KB
testcase_34 AC 311 ms
77,932 KB
testcase_35 AC 103 ms
77,772 KB
testcase_36 AC 293 ms
77,960 KB
testcase_37 AC 75 ms
71,124 KB
testcase_38 AC 102 ms
77,712 KB
testcase_39 AC 79 ms
76,140 KB
testcase_40 AC 107 ms
77,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter

N,M=map(int,input().split())

J=[]
for _ in range(N):
    v,w=map(int,input().split())
    J.append((v,w))

J.sort(key=itemgetter(0),reverse=True)

DP=[0]*(M+1)
Ans=0
for v,w in J:
    for x in range(M,w-1,-1):
        Ans=max(Ans,v*(DP[x-w]+v))
        DP[x]=max(DP[x], DP[x-w]+v)

print(Ans)
0