結果

問題 No.2232 Miser's Gift
ユーザー lloyzlloyz
提出日時 2023-03-07 01:10:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 81,556 KB
実行使用メモリ 156,304 KB
最終ジャッジ日時 2023-10-18 05:21:42
合計ジャッジ時間 12,960 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,300 KB
testcase_01 AC 38 ms
53,300 KB
testcase_02 AC 38 ms
53,300 KB
testcase_03 AC 217 ms
156,040 KB
testcase_04 AC 330 ms
156,040 KB
testcase_05 AC 79 ms
83,372 KB
testcase_06 AC 37 ms
53,300 KB
testcase_07 AC 70 ms
78,424 KB
testcase_08 AC 201 ms
156,040 KB
testcase_09 AC 204 ms
156,040 KB
testcase_10 AC 204 ms
156,040 KB
testcase_11 AC 201 ms
156,040 KB
testcase_12 AC 200 ms
156,040 KB
testcase_13 AC 209 ms
156,040 KB
testcase_14 AC 208 ms
156,040 KB
testcase_15 AC 208 ms
156,040 KB
testcase_16 AC 209 ms
156,040 KB
testcase_17 AC 211 ms
156,040 KB
testcase_18 AC 210 ms
156,040 KB
testcase_19 AC 205 ms
156,040 KB
testcase_20 AC 209 ms
156,040 KB
testcase_21 AC 210 ms
156,040 KB
testcase_22 AC 208 ms
156,040 KB
testcase_23 AC 371 ms
156,040 KB
testcase_24 AC 380 ms
156,040 KB
testcase_25 AC 372 ms
156,040 KB
testcase_26 AC 372 ms
156,040 KB
testcase_27 AC 377 ms
156,040 KB
testcase_28 AC 299 ms
156,040 KB
testcase_29 AC 297 ms
156,040 KB
testcase_30 AC 297 ms
156,040 KB
testcase_31 AC 297 ms
156,040 KB
testcase_32 AC 302 ms
156,040 KB
testcase_33 AC 223 ms
156,304 KB
testcase_34 AC 225 ms
156,040 KB
testcase_35 AC 223 ms
156,040 KB
testcase_36 AC 220 ms
156,040 KB
testcase_37 AC 224 ms
156,040 KB
testcase_38 AC 60 ms
65,900 KB
testcase_39 AC 62 ms
67,960 KB
testcase_40 AC 62 ms
67,960 KB
testcase_41 AC 62 ms
67,960 KB
testcase_42 AC 61 ms
67,948 KB
testcase_43 AC 62 ms
67,960 KB
testcase_44 AC 64 ms
67,960 KB
testcase_45 AC 62 ms
67,960 KB
testcase_46 AC 61 ms
65,900 KB
testcase_47 AC 61 ms
65,900 KB
testcase_48 AC 53 ms
63,648 KB
testcase_49 AC 51 ms
63,640 KB
testcase_50 AC 56 ms
63,664 KB
testcase_51 AC 54 ms
63,664 KB
testcase_52 AC 53 ms
63,656 KB
testcase_53 AC 52 ms
63,660 KB
testcase_54 AC 52 ms
63,660 KB
testcase_55 AC 53 ms
63,664 KB
testcase_56 AC 54 ms
63,660 KB
testcase_57 AC 53 ms
63,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = map(int, input().split())
DP = [[-1 for _ in range(w + 1)] for _ in range(n + 1)]
DP[0][0] = 0
for i in range(n):
    ww, vv = map(int, input().split())
    for j in range(w + 1):
        if DP[i][j] != -1:
            DP[i + 1][j] = max(DP[i + 1][j], DP[i][j])
            if j + ww <= w:
                DP[i + 1][j + ww] = max(DP[i + 1][j + ww], DP[i][j] + vv)
for i in range(1, w + 1):
    DP[n][i] = max(DP[n][i], DP[n][i - 1])
for i in range(1, w + 1):
    print(DP[n][w] - DP[n][w - i] + 1)
0