結果

問題 No.2232 Miser's Gift
ユーザー rlangevinrlangevin
提出日時 2023-03-03 21:31:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 81,364 KB
実行使用メモリ 160,712 KB
最終ジャッジ日時 2023-10-18 01:26:21
合計ジャッジ時間 13,539 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,292 KB
testcase_01 AC 38 ms
53,292 KB
testcase_02 AC 37 ms
53,292 KB
testcase_03 AC 228 ms
160,208 KB
testcase_04 AC 310 ms
160,448 KB
testcase_05 AC 80 ms
76,048 KB
testcase_06 AC 38 ms
53,292 KB
testcase_07 AC 75 ms
82,832 KB
testcase_08 AC 251 ms
160,448 KB
testcase_09 AC 254 ms
160,448 KB
testcase_10 AC 247 ms
160,448 KB
testcase_11 AC 311 ms
160,448 KB
testcase_12 AC 257 ms
160,448 KB
testcase_13 AC 226 ms
160,448 KB
testcase_14 AC 228 ms
160,488 KB
testcase_15 AC 230 ms
160,448 KB
testcase_16 AC 227 ms
160,712 KB
testcase_17 AC 226 ms
160,448 KB
testcase_18 AC 225 ms
160,712 KB
testcase_19 AC 224 ms
160,712 KB
testcase_20 AC 224 ms
160,712 KB
testcase_21 AC 225 ms
160,712 KB
testcase_22 AC 227 ms
160,448 KB
testcase_23 AC 373 ms
160,448 KB
testcase_24 AC 370 ms
160,448 KB
testcase_25 AC 365 ms
160,448 KB
testcase_26 AC 374 ms
160,448 KB
testcase_27 AC 355 ms
160,448 KB
testcase_28 AC 271 ms
160,448 KB
testcase_29 AC 276 ms
160,448 KB
testcase_30 AC 277 ms
160,448 KB
testcase_31 AC 317 ms
160,448 KB
testcase_32 AC 317 ms
160,448 KB
testcase_33 AC 230 ms
160,712 KB
testcase_34 AC 230 ms
160,712 KB
testcase_35 AC 231 ms
160,448 KB
testcase_36 AC 230 ms
160,448 KB
testcase_37 AC 237 ms
160,448 KB
testcase_38 AC 58 ms
65,796 KB
testcase_39 AC 58 ms
65,796 KB
testcase_40 AC 58 ms
65,796 KB
testcase_41 AC 57 ms
65,796 KB
testcase_42 AC 57 ms
65,808 KB
testcase_43 AC 57 ms
65,796 KB
testcase_44 AC 56 ms
65,808 KB
testcase_45 AC 57 ms
65,808 KB
testcase_46 AC 56 ms
63,756 KB
testcase_47 AC 56 ms
65,808 KB
testcase_48 AC 49 ms
61,504 KB
testcase_49 AC 49 ms
61,504 KB
testcase_50 AC 50 ms
61,504 KB
testcase_51 AC 49 ms
61,504 KB
testcase_52 AC 49 ms
61,504 KB
testcase_53 AC 50 ms
61,504 KB
testcase_54 AC 49 ms
61,500 KB
testcase_55 AC 49 ms
61,504 KB
testcase_56 AC 50 ms
61,504 KB
testcase_57 AC 50 ms
61,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
inf = 10 ** 18
A, B = [0] * N, [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
    
pre = [-inf] * (W + 1)
pre[0] = 0
for i in range(N):
    dp = [-inf] * (W + 1)
    for w in range(W + 1):
        dp[w] = pre[w]
        if w - A[i] >= 0:
            dp[w] = max(dp[w], pre[w - A[i]] + B[i])
    dp, pre = pre, dp
ans = []
for i in range(1, W + 1):
    pre[i] = max(pre[i], pre[i - 1])
for i in range(W):
    ans.append(pre[-1] - pre[i] + 1)
ans.reverse()
for i in ans:
    print(i)
0