結果

問題 No.2232 Miser's Gift
ユーザー floraflora
提出日時 2023-03-03 22:34:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,305 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 156,180 KB
最終ジャッジ日時 2023-10-18 02:42:33
合計ジャッジ時間 12,469 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,468 KB
testcase_01 AC 38 ms
53,468 KB
testcase_02 AC 38 ms
53,468 KB
testcase_03 AC 233 ms
156,172 KB
testcase_04 AC 254 ms
156,180 KB
testcase_05 AC 71 ms
73,980 KB
testcase_06 AC 38 ms
53,468 KB
testcase_07 AC 69 ms
78,556 KB
testcase_08 AC 258 ms
156,180 KB
testcase_09 AC 263 ms
156,180 KB
testcase_10 AC 256 ms
156,180 KB
testcase_11 AC 314 ms
156,180 KB
testcase_12 AC 260 ms
156,180 KB
testcase_13 AC 233 ms
156,180 KB
testcase_14 AC 233 ms
156,180 KB
testcase_15 AC 231 ms
156,180 KB
testcase_16 AC 231 ms
156,180 KB
testcase_17 AC 231 ms
156,180 KB
testcase_18 AC 232 ms
156,180 KB
testcase_19 AC 232 ms
156,180 KB
testcase_20 AC 233 ms
156,180 KB
testcase_21 AC 233 ms
156,180 KB
testcase_22 AC 234 ms
156,180 KB
testcase_23 AC 343 ms
156,180 KB
testcase_24 AC 342 ms
156,176 KB
testcase_25 AC 359 ms
156,180 KB
testcase_26 AC 345 ms
156,180 KB
testcase_27 AC 338 ms
156,180 KB
testcase_28 AC 261 ms
156,180 KB
testcase_29 AC 261 ms
156,180 KB
testcase_30 AC 260 ms
156,180 KB
testcase_31 AC 303 ms
156,180 KB
testcase_32 AC 301 ms
156,180 KB
testcase_33 AC 235 ms
156,180 KB
testcase_34 AC 237 ms
156,180 KB
testcase_35 AC 237 ms
156,180 KB
testcase_36 AC 238 ms
156,180 KB
testcase_37 AC 244 ms
156,180 KB
testcase_38 AC 57 ms
66,028 KB
testcase_39 AC 57 ms
66,028 KB
testcase_40 AC 58 ms
66,028 KB
testcase_41 AC 57 ms
66,028 KB
testcase_42 AC 58 ms
66,032 KB
testcase_43 AC 58 ms
66,028 KB
testcase_44 AC 57 ms
66,032 KB
testcase_45 AC 58 ms
66,032 KB
testcase_46 AC 58 ms
66,032 KB
testcase_47 AC 58 ms
66,032 KB
testcase_48 AC 50 ms
61,736 KB
testcase_49 AC 50 ms
61,736 KB
testcase_50 AC 50 ms
61,736 KB
testcase_51 AC 51 ms
61,736 KB
testcase_52 AC 50 ms
61,736 KB
testcase_53 AC 50 ms
61,736 KB
testcase_54 AC 50 ms
61,736 KB
testcase_55 AC 50 ms
61,736 KB
testcase_56 AC 50 ms
61,736 KB
testcase_57 AC 52 ms
61,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W=map(int,input().split())
w,v=[],[]
for _ in range(N):
    hw,hv=map(int,input().split())
    w.append(hw)
    v.append(hv)

#ふつうにdpするとdp[i][j]=i番目までみて重さがj以下の価値の最大値、がわかるので、すべての重さに対して価値の最大値がわかっていると言える。
#Vが確実に選ばれるのはW-xの最大の価値+V>Wの最大の価値がなりたつとき?

dp=[[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(1,W+1):
        if j-w[i-1]>=0:
            dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]


for x in range(1,W+1):
    print(dp[N][W]-dp[N][W-x]+1)
0