結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 H20H20
提出日時 2022-02-27 20:02:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 78,540 KB
最終ジャッジ日時 2023-09-19 07:19:28
合計ジャッジ時間 8,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,300 KB
testcase_01 AC 74 ms
71,324 KB
testcase_02 AC 72 ms
71,340 KB
testcase_03 AC 85 ms
76,000 KB
testcase_04 AC 196 ms
78,012 KB
testcase_05 AC 115 ms
76,896 KB
testcase_06 AC 217 ms
77,796 KB
testcase_07 AC 166 ms
78,380 KB
testcase_08 AC 270 ms
78,248 KB
testcase_09 AC 388 ms
78,196 KB
testcase_10 AC 199 ms
78,172 KB
testcase_11 AC 239 ms
78,540 KB
testcase_12 AC 336 ms
78,412 KB
testcase_13 AC 135 ms
78,332 KB
testcase_14 AC 84 ms
75,960 KB
testcase_15 AC 83 ms
76,464 KB
testcase_16 AC 81 ms
75,940 KB
testcase_17 AC 75 ms
71,320 KB
testcase_18 AC 74 ms
71,152 KB
testcase_19 AC 74 ms
71,456 KB
testcase_20 AC 73 ms
71,516 KB
testcase_21 AC 73 ms
71,312 KB
testcase_22 AC 73 ms
71,464 KB
testcase_23 AC 73 ms
71,156 KB
testcase_24 AC 126 ms
77,120 KB
testcase_25 AC 273 ms
78,500 KB
testcase_26 AC 251 ms
77,988 KB
testcase_27 AC 240 ms
77,992 KB
testcase_28 AC 200 ms
78,300 KB
testcase_29 AC 114 ms
77,684 KB
testcase_30 AC 119 ms
78,052 KB
testcase_31 AC 118 ms
78,104 KB
testcase_32 AC 114 ms
77,948 KB
testcase_33 AC 120 ms
78,096 KB
testcase_34 AC 414 ms
78,380 KB
testcase_35 AC 263 ms
78,208 KB
testcase_36 AC 428 ms
78,488 KB
testcase_37 AC 73 ms
71,300 KB
testcase_38 AC 113 ms
77,772 KB
testcase_39 AC 78 ms
75,744 KB
testcase_40 AC 263 ms
78,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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:
            DP[i+m] = max(DP[i+m],DP[i]+v)
    if m<=M:
        DP[m]=max(DP[m],v)
    ans=max(ans,max(DP)*v)
print(ans)
0