結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,552 KB
testcase_01 AC 34 ms
53,552 KB
testcase_02 AC 33 ms
53,552 KB
testcase_03 AC 33 ms
53,552 KB
testcase_04 AC 55 ms
70,432 KB
testcase_05 WA -
testcase_06 AC 53 ms
68,356 KB
testcase_07 AC 60 ms
70,440 KB
testcase_08 AC 59 ms
73,048 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 217 ms
103,312 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 95 ms
83,480 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 57 ms
70,364 KB
testcase_29 AC 1,194 ms
274,488 KB
testcase_30 WA -
testcase_31 AC 36 ms
53,552 KB
testcase_32 AC 34 ms
53,552 KB
testcase_33 WA -
testcase_34 AC 570 ms
273,064 KB
testcase_35 AC 510 ms
272,616 KB
testcase_36 AC 1,185 ms
277,708 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-1][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