結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 H20H20
提出日時 2022-02-27 20:18:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 426 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 78,452 KB
最終ジャッジ日時 2023-09-19 07:37:53
合計ジャッジ時間 9,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,284 KB
testcase_01 AC 74 ms
71,000 KB
testcase_02 AC 72 ms
71,220 KB
testcase_03 AC 99 ms
75,796 KB
testcase_04 AC 196 ms
77,624 KB
testcase_05 AC 112 ms
77,108 KB
testcase_06 AC 213 ms
77,808 KB
testcase_07 AC 166 ms
78,252 KB
testcase_08 AC 273 ms
78,280 KB
testcase_09 AC 379 ms
77,976 KB
testcase_10 AC 190 ms
78,108 KB
testcase_11 AC 233 ms
78,228 KB
testcase_12 AC 327 ms
78,264 KB
testcase_13 AC 132 ms
78,452 KB
testcase_14 AC 80 ms
75,880 KB
testcase_15 AC 78 ms
76,484 KB
testcase_16 AC 78 ms
75,960 KB
testcase_17 AC 74 ms
71,308 KB
testcase_18 AC 75 ms
71,360 KB
testcase_19 AC 74 ms
71,048 KB
testcase_20 AC 74 ms
71,244 KB
testcase_21 AC 74 ms
71,112 KB
testcase_22 AC 75 ms
71,288 KB
testcase_23 AC 75 ms
71,296 KB
testcase_24 AC 127 ms
77,268 KB
testcase_25 AC 271 ms
78,328 KB
testcase_26 AC 249 ms
77,756 KB
testcase_27 AC 239 ms
77,852 KB
testcase_28 AC 200 ms
78,368 KB
testcase_29 AC 120 ms
77,804 KB
testcase_30 AC 121 ms
77,948 KB
testcase_31 AC 119 ms
78,056 KB
testcase_32 AC 114 ms
77,552 KB
testcase_33 AC 121 ms
78,092 KB
testcase_34 AC 411 ms
78,192 KB
testcase_35 AC 264 ms
78,120 KB
testcase_36 AC 426 ms
78,012 KB
testcase_37 AC 73 ms
71,108 KB
testcase_38 AC 111 ms
77,816 KB
testcase_39 AC 76 ms
75,692 KB
testcase_40 AC 263 ms
78,156 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:
            continue
        if 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