結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 H20H20
提出日時 2022-02-27 20:04:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 1,356 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 78,544 KB
最終ジャッジ日時 2023-09-19 07:23:19
合計ジャッジ時間 9,533 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,300 KB
testcase_01 AC 77 ms
71,292 KB
testcase_02 AC 77 ms
71,484 KB
testcase_03 AC 95 ms
76,100 KB
testcase_04 AC 202 ms
77,980 KB
testcase_05 AC 117 ms
77,152 KB
testcase_06 AC 222 ms
77,904 KB
testcase_07 AC 171 ms
78,288 KB
testcase_08 AC 275 ms
78,396 KB
testcase_09 AC 386 ms
78,292 KB
testcase_10 AC 198 ms
78,544 KB
testcase_11 AC 238 ms
78,340 KB
testcase_12 AC 332 ms
78,380 KB
testcase_13 AC 138 ms
78,272 KB
testcase_14 AC 84 ms
75,996 KB
testcase_15 AC 83 ms
76,504 KB
testcase_16 AC 84 ms
76,336 KB
testcase_17 AC 79 ms
71,588 KB
testcase_18 AC 78 ms
71,524 KB
testcase_19 AC 79 ms
71,536 KB
testcase_20 AC 76 ms
71,388 KB
testcase_21 AC 75 ms
71,412 KB
testcase_22 AC 78 ms
71,384 KB
testcase_23 AC 77 ms
71,420 KB
testcase_24 AC 128 ms
77,436 KB
testcase_25 AC 273 ms
78,368 KB
testcase_26 AC 252 ms
78,072 KB
testcase_27 AC 247 ms
77,896 KB
testcase_28 AC 200 ms
78,520 KB
testcase_29 AC 124 ms
78,080 KB
testcase_30 AC 129 ms
78,224 KB
testcase_31 AC 122 ms
78,308 KB
testcase_32 AC 121 ms
78,012 KB
testcase_33 AC 124 ms
78,176 KB
testcase_34 AC 421 ms
78,520 KB
testcase_35 AC 273 ms
78,344 KB
testcase_36 AC 436 ms
78,260 KB
testcase_37 AC 76 ms
71,580 KB
testcase_38 AC 112 ms
78,004 KB
testcase_39 AC 79 ms
75,920 KB
testcase_40 AC 265 ms
78,388 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 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)
0