結果

問題 No.2232 Miser's Gift
ユーザー n_nan_na
提出日時 2023-03-03 23:35:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 157,092 KB
最終ジャッジ日時 2023-10-18 03:45:45
合計ジャッジ時間 14,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
64,364 KB
testcase_01 AC 51 ms
64,372 KB
testcase_02 AC 51 ms
65,148 KB
testcase_03 AC 205 ms
157,024 KB
testcase_04 AC 302 ms
157,092 KB
testcase_05 AC 165 ms
149,372 KB
testcase_06 AC 46 ms
62,648 KB
testcase_07 AC 68 ms
79,352 KB
testcase_08 AC 180 ms
157,092 KB
testcase_09 AC 181 ms
157,092 KB
testcase_10 AC 184 ms
157,092 KB
testcase_11 AC 181 ms
157,092 KB
testcase_12 AC 180 ms
157,092 KB
testcase_13 AC 194 ms
157,032 KB
testcase_14 AC 193 ms
157,032 KB
testcase_15 AC 194 ms
157,032 KB
testcase_16 AC 193 ms
157,032 KB
testcase_17 AC 196 ms
157,032 KB
testcase_18 AC 193 ms
157,032 KB
testcase_19 AC 193 ms
157,032 KB
testcase_20 AC 196 ms
157,032 KB
testcase_21 AC 195 ms
157,032 KB
testcase_22 AC 193 ms
157,032 KB
testcase_23 AC 354 ms
157,092 KB
testcase_24 AC 362 ms
157,092 KB
testcase_25 AC 354 ms
157,092 KB
testcase_26 AC 356 ms
157,092 KB
testcase_27 AC 358 ms
157,092 KB
testcase_28 AC 284 ms
157,092 KB
testcase_29 AC 280 ms
157,092 KB
testcase_30 AC 277 ms
157,092 KB
testcase_31 AC 279 ms
157,092 KB
testcase_32 AC 281 ms
157,092 KB
testcase_33 AC 210 ms
157,032 KB
testcase_34 AC 212 ms
157,032 KB
testcase_35 AC 213 ms
157,032 KB
testcase_36 AC 210 ms
157,032 KB
testcase_37 AC 211 ms
157,032 KB
testcase_38 AC 169 ms
146,824 KB
testcase_39 AC 173 ms
146,844 KB
testcase_40 AC 169 ms
146,832 KB
testcase_41 AC 171 ms
146,844 KB
testcase_42 AC 171 ms
146,836 KB
testcase_43 AC 172 ms
146,836 KB
testcase_44 AC 174 ms
146,836 KB
testcase_45 AC 172 ms
146,836 KB
testcase_46 AC 172 ms
146,832 KB
testcase_47 AC 170 ms
146,832 KB
testcase_48 AC 166 ms
144,596 KB
testcase_49 AC 167 ms
146,648 KB
testcase_50 AC 165 ms
144,596 KB
testcase_51 AC 162 ms
144,580 KB
testcase_52 AC 165 ms
144,580 KB
testcase_53 AC 165 ms
144,596 KB
testcase_54 AC 164 ms
146,648 KB
testcase_55 AC 166 ms
144,584 KB
testcase_56 AC 164 ms
144,580 KB
testcase_57 AC 165 ms
144,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W = map(int,input().split())

mx = 10**5
dp = [[-1]*(mx+3) for _ in range(N+3)]
dp[0][0] = 0

for i in range(N):
    w,v = map(int,input().split())
    for j in range(mx+1):
        if dp[i][j] == -1: continue
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
        if j+w <= mx:
            dp[i+1][j+w] = max(dp[i][j]+v, dp[i+1][j+w])

Vmax = max(dp[N][:W+1])
for j in range(1,mx+1):
    dp[N][j] = max(dp[N][j-1], dp[N][j])
    
for x in range(1,W+1):
    rem = W - x
    Vtmp = dp[N][rem]
    Vbob = (Vmax - Vtmp) + 1
    print(Vbob)
            
#for i in range(N+3):
#    print(*dp[i][:W+3])

    
0