結果

問題 No.1947 質より種類数
ユーザー june19312june19312
提出日時 2022-05-21 14:39:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 277,696 KB
最終ジャッジ日時 2023-10-20 16:15:09
合計ジャッジ時間 12,691 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,552 KB
testcase_01 AC 37 ms
53,552 KB
testcase_02 AC 36 ms
53,552 KB
testcase_03 AC 33 ms
53,552 KB
testcase_04 AC 55 ms
70,428 KB
testcase_05 WA -
testcase_06 AC 53 ms
68,356 KB
testcase_07 AC 56 ms
70,436 KB
testcase_08 AC 58 ms
73,040 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 199 ms
103,308 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 101 ms
83,484 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 58 ms
70,360 KB
testcase_29 AC 1,222 ms
274,392 KB
testcase_30 WA -
testcase_31 AC 37 ms
53,552 KB
testcase_32 AC 36 ms
53,552 KB
testcase_33 WA -
testcase_34 AC 578 ms
273,064 KB
testcase_35 AC 523 ms
272,616 KB
testcase_36 AC 1,124 ms
277,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C = map(int,input().split())

vs = [] #値段
ws = [] #価値

for i in range(N):
    v,w = map(int,input().split())
    vs.append(v)
    ws.append(w)

dp = []  #購入したものの価値総計

for i in range(N):
    dp.append([-1]*(V+1))

dp[0][0] = 0

for i in range(N):
    tmp = []
    if i>=1:
        for ii in range(V+1):
            dp[i][ii] = max(dp[i-1][ii],dp[i][ii])

    for ii in range(V+1):
        if dp[i][ii] != -1:
            if ii+vs[i]<=V:
                if dp[i][ii+vs[i]] < dp[i][ii]+ws[i]+C:
                    dp[i][ii+vs[i]] = dp[i][ii]+ws[i]
                    tmp.append(ii+vs[i])

    for j in tmp:
        dp[i][j]+=C

ans = 0
for i in dp[-1]:
    ans = max(ans,i)

print(ans)
0