結果

問題 No.1858 Gorgeous Knapsack
ユーザー DrDrpilotDrDrpilot
提出日時 2022-03-22 17:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 741 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,664 KB
実行使用メモリ 273,280 KB
最終ジャッジ日時 2024-04-18 16:21:52
合計ジャッジ時間 8,958 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,480 KB
testcase_01 AC 40 ms
52,096 KB
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 57 ms
64,896 KB
testcase_04 AC 231 ms
105,856 KB
testcase_05 AC 93 ms
82,944 KB
testcase_06 AC 266 ms
123,136 KB
testcase_07 AC 181 ms
102,656 KB
testcase_08 AC 289 ms
143,360 KB
testcase_09 AC 512 ms
191,104 KB
testcase_10 AC 193 ms
99,072 KB
testcase_11 AC 290 ms
122,240 KB
testcase_12 AC 363 ms
166,016 KB
testcase_13 AC 107 ms
77,312 KB
testcase_14 AC 49 ms
60,672 KB
testcase_15 AC 44 ms
59,776 KB
testcase_16 AC 47 ms
60,928 KB
testcase_17 AC 37 ms
52,608 KB
testcase_18 AC 40 ms
52,480 KB
testcase_19 AC 39 ms
52,224 KB
testcase_20 AC 38 ms
52,224 KB
testcase_21 AC 39 ms
52,096 KB
testcase_22 AC 38 ms
52,352 KB
testcase_23 AC 38 ms
51,840 KB
testcase_24 AC 122 ms
89,472 KB
testcase_25 AC 367 ms
145,416 KB
testcase_26 AC 314 ms
126,604 KB
testcase_27 AC 305 ms
126,416 KB
testcase_28 AC 236 ms
119,808 KB
testcase_29 AC 88 ms
77,312 KB
testcase_30 AC 89 ms
77,300 KB
testcase_31 AC 87 ms
77,056 KB
testcase_32 AC 85 ms
76,880 KB
testcase_33 AC 95 ms
77,140 KB
testcase_34 AC 741 ms
272,900 KB
testcase_35 AC 468 ms
272,896 KB
testcase_36 AC 735 ms
273,280 KB
testcase_37 AC 38 ms
51,584 KB
testcase_38 AC 79 ms
77,268 KB
testcase_39 AC 47 ms
59,008 KB
testcase_40 AC 463 ms
272,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
item=[list(map(int,input().split())) for _ in range(n)]
item.sort(reverse=True)
dp=[[0]*(1+m) for _ in range(n+1)]
ans=0
for i in range(n):
    v,w=item[i]
    for j in range(m+1):
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j+w<=m:
            if dp[i+1][j+w]<dp[i][j]+v:
                dp[i+1][j+w]=dp[i][j]+v
                ans=max(ans,v*dp[i+1][j+w])
print(ans)
0