結果

問題 No.1947 質より種類数
ユーザー abababab
提出日時 2022-05-20 23:38:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 730 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2023-10-20 14:34:30
合計ジャッジ時間 10,173 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,492 KB
testcase_01 AC 33 ms
53,492 KB
testcase_02 AC 32 ms
53,492 KB
testcase_03 AC 31 ms
53,492 KB
testcase_04 AC 63 ms
73,164 KB
testcase_05 AC 59 ms
70,540 KB
testcase_06 AC 64 ms
73,156 KB
testcase_07 AC 61 ms
72,612 KB
testcase_08 AC 62 ms
72,616 KB
testcase_09 AC 77 ms
75,688 KB
testcase_10 AC 76 ms
75,664 KB
testcase_11 AC 110 ms
75,972 KB
testcase_12 AC 95 ms
75,724 KB
testcase_13 AC 77 ms
75,900 KB
testcase_14 AC 251 ms
76,712 KB
testcase_15 AC 162 ms
76,148 KB
testcase_16 AC 425 ms
76,776 KB
testcase_17 AC 481 ms
76,864 KB
testcase_18 AC 730 ms
77,124 KB
testcase_19 AC 684 ms
77,184 KB
testcase_20 AC 489 ms
77,040 KB
testcase_21 AC 589 ms
77,028 KB
testcase_22 AC 92 ms
76,048 KB
testcase_23 AC 356 ms
76,756 KB
testcase_24 AC 59 ms
70,548 KB
testcase_25 AC 60 ms
70,556 KB
testcase_26 AC 54 ms
68,480 KB
testcase_27 AC 60 ms
70,548 KB
testcase_28 AC 69 ms
73,160 KB
testcase_29 AC 395 ms
77,124 KB
testcase_30 AC 362 ms
77,124 KB
testcase_31 AC 35 ms
53,492 KB
testcase_32 AC 33 ms
53,492 KB
testcase_33 AC 42 ms
62,260 KB
testcase_34 AC 486 ms
77,172 KB
testcase_35 AC 177 ms
76,936 KB
testcase_36 AC 368 ms
77,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, V, C = map(int, input().split())
vw = [tuple(map(int, input().split())) for _ in range(n)]

INF = float('inf')
ndp = [-INF] * (V + 1)
ndp[0] = 0

for v, w in vw:
    dp = ndp[:]
    for i in range(V + 1):
        if i + v <= V:
            ndp[i + v] = max(ndp[i + v], dp[i] + w + C)
    for i in range(V + 1):
        if i + v <= V:
            ndp[i + v] = max(ndp[i + v], ndp[i] + w)

print(max(ndp))
0