結果

問題 No.1947 質より種類数
ユーザー hashi_pyhashi_py
提出日時 2022-05-20 22:43:03
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,071 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 272,200 KB
最終ジャッジ日時 2023-10-20 13:30:55
合計ジャッジ時間 11,896 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,428 KB
testcase_01 AC 39 ms
53,428 KB
testcase_02 AC 40 ms
53,428 KB
testcase_03 AC 39 ms
53,428 KB
testcase_04 AC 67 ms
68,008 KB
testcase_05 AC 59 ms
65,912 KB
testcase_06 AC 59 ms
65,912 KB
testcase_07 AC 60 ms
65,912 KB
testcase_08 AC 66 ms
68,008 KB
testcase_09 AC 76 ms
70,008 KB
testcase_10 AC 70 ms
67,960 KB
testcase_11 AC 116 ms
85,316 KB
testcase_12 AC 87 ms
72,056 KB
testcase_13 AC 67 ms
67,960 KB
testcase_14 AC 358 ms
128,784 KB
testcase_15 AC 191 ms
89,660 KB
testcase_16 AC 457 ms
151,344 KB
testcase_17 AC 569 ms
173,832 KB
testcase_18 AC 957 ms
261,624 KB
testcase_19 AC 841 ms
238,008 KB
testcase_20 AC 659 ms
196,572 KB
testcase_21 AC 760 ms
219,128 KB
testcase_22 AC 105 ms
83,388 KB
testcase_23 AC 375 ms
128,536 KB
testcase_24 AC 62 ms
65,912 KB
testcase_25 AC 62 ms
65,924 KB
testcase_26 AC 59 ms
65,920 KB
testcase_27 AC 61 ms
65,920 KB
testcase_28 AC 63 ms
65,940 KB
testcase_29 AC 1,071 ms
272,200 KB
testcase_30 AC 864 ms
272,032 KB
testcase_31 AC 39 ms
53,428 KB
testcase_32 AC 39 ms
53,428 KB
testcase_33 AC 50 ms
61,772 KB
testcase_34 AC 489 ms
272,016 KB
testcase_35 AC 478 ms
271,764 KB
testcase_36 AC 861 ms
272,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v,c = map(int,input().split())
V = []
W = []
for i in range(n):
    a,b = map(int,input().split())
    W.append(a)
    V.append(b)

dp = [[0]*(v+1) for _ in range(n+1)]

for i in range(n):
    for j in range(v+1):
        dp[i+1][j]=dp[i][j]
        if(j-W[i]>=0):
            if(dp[i+1][j]<dp[i][j-W[i]]+V[i]+c):
                dp[i+1][j]=dp[i][j-W[i]]+V[i]+c
            # dp[i+1][j]=max(dp[i+1][j],dp[i][j-W[i]]+V[i])
        if(j-W[i]>=0):
            dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-W[i]]+V[i])

print(dp[-1][-1])
0