結果

問題 No.1947 質より種類数
ユーザー lloyzlloyz
提出日時 2022-05-21 00:49:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,041 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 272,708 KB
最終ジャッジ日時 2023-10-20 15:21:06
合計ジャッジ時間 11,899 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,448 KB
testcase_01 AC 34 ms
53,448 KB
testcase_02 AC 37 ms
53,448 KB
testcase_03 AC 32 ms
53,448 KB
testcase_04 AC 105 ms
68,336 KB
testcase_05 AC 51 ms
68,344 KB
testcase_06 AC 58 ms
70,956 KB
testcase_07 AC 54 ms
68,332 KB
testcase_08 AC 54 ms
68,332 KB
testcase_09 AC 74 ms
72,472 KB
testcase_10 AC 68 ms
72,456 KB
testcase_11 AC 102 ms
85,704 KB
testcase_12 AC 98 ms
82,240 KB
testcase_13 AC 64 ms
70,408 KB
testcase_14 AC 324 ms
126,324 KB
testcase_15 AC 176 ms
103,848 KB
testcase_16 AC 493 ms
148,272 KB
testcase_17 AC 447 ms
170,340 KB
testcase_18 AC 1,041 ms
258,804 KB
testcase_19 AC 654 ms
236,248 KB
testcase_20 AC 502 ms
192,556 KB
testcase_21 AC 846 ms
214,076 KB
testcase_22 AC 93 ms
83,648 KB
testcase_23 AC 371 ms
140,516 KB
testcase_24 AC 58 ms
66,268 KB
testcase_25 AC 57 ms
66,204 KB
testcase_26 AC 54 ms
66,208 KB
testcase_27 AC 52 ms
66,188 KB
testcase_28 AC 60 ms
68,832 KB
testcase_29 AC 830 ms
258,072 KB
testcase_30 AC 768 ms
258,060 KB
testcase_31 AC 32 ms
53,448 KB
testcase_32 AC 34 ms
53,448 KB
testcase_33 AC 44 ms
62,068 KB
testcase_34 AC 582 ms
272,708 KB
testcase_35 AC 450 ms
257,984 KB
testcase_36 AC 745 ms
258,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, v, c = map(int, input().split())
VW = [list(map(int, input().split())) for _ in range(n)]

INF = 10**18
DP = [[-INF for _ in range(v + 1)] for _ in range(n + 1)]
DP[0][0] = 0
for i in range(n):
    cv, cw = VW[i]
    for j in range(v + 1):
        if j >= cv:
            DP[i + 1][j] = max(DP[i + 1][j], DP[i][j], DP[i][j - cv] + cw + c)
        else:
            DP[i + 1][j] = max(DP[i + 1][j], DP[i][j])
    for j in range(cv, v + 1):
        DP[i + 1][j] = max(DP[i + 1][j], DP[i + 1][j - cv] + cw)
print(max(DP[-1]))
0