結果

問題 No.1858 Gorgeous Knapsack
ユーザー 👑 rin204rin204
提出日時 2022-02-27 14:50:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 608 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 78,500 KB
最終ジャッジ日時 2023-09-19 01:35:06
合計ジャッジ時間 9,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,360 KB
testcase_01 AC 73 ms
71,432 KB
testcase_02 AC 74 ms
71,488 KB
testcase_03 AC 83 ms
75,788 KB
testcase_04 AC 164 ms
77,968 KB
testcase_05 AC 102 ms
76,888 KB
testcase_06 AC 161 ms
78,104 KB
testcase_07 AC 132 ms
78,092 KB
testcase_08 AC 186 ms
77,800 KB
testcase_09 AC 235 ms
78,452 KB
testcase_10 AC 150 ms
78,084 KB
testcase_11 AC 171 ms
78,276 KB
testcase_12 AC 198 ms
78,372 KB
testcase_13 AC 121 ms
78,036 KB
testcase_14 AC 82 ms
75,952 KB
testcase_15 AC 72 ms
71,420 KB
testcase_16 AC 77 ms
75,844 KB
testcase_17 AC 72 ms
71,332 KB
testcase_18 AC 75 ms
71,368 KB
testcase_19 AC 72 ms
71,444 KB
testcase_20 AC 71 ms
71,360 KB
testcase_21 AC 70 ms
71,276 KB
testcase_22 AC 73 ms
71,076 KB
testcase_23 AC 74 ms
71,272 KB
testcase_24 AC 114 ms
77,084 KB
testcase_25 AC 165 ms
78,164 KB
testcase_26 AC 170 ms
78,088 KB
testcase_27 AC 171 ms
78,056 KB
testcase_28 AC 137 ms
78,052 KB
testcase_29 AC 110 ms
77,884 KB
testcase_30 AC 110 ms
77,664 KB
testcase_31 AC 108 ms
78,272 KB
testcase_32 AC 111 ms
78,148 KB
testcase_33 AC 112 ms
77,728 KB
testcase_34 AC 608 ms
78,500 KB
testcase_35 AC 107 ms
77,964 KB
testcase_36 AC 303 ms
77,776 KB
testcase_37 AC 72 ms
70,932 KB
testcase_38 AC 105 ms
77,952 KB
testcase_39 AC 77 ms
75,772 KB
testcase_40 AC 107 ms
77,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(n)]
vw.sort(key = lambda x:-x[0])

inf = 1 << 60
dp = [-inf] * (m + 1)
dp[0] = 0
ans = 0
for v, w in vw:
    for i in range(m, w - 1, -1):
        ans = max(ans, (dp[i - w] + v) * v)
        dp[i] = max(dp[i], dp[i - w] + v)
print(ans)
0