結果

問題 No.1947 質より種類数
ユーザー june19312june19312
提出日時 2022-05-21 13:47:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 656 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 266,280 KB
最終ジャッジ日時 2023-10-20 16:10:47
合計ジャッジ時間 13,045 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
57,836 KB
testcase_01 AC 37 ms
53,448 KB
testcase_02 AC 36 ms
53,448 KB
testcase_03 AC 37 ms
53,448 KB
testcase_04 AC 260 ms
72,544 KB
testcase_05 AC 298 ms
70,492 KB
testcase_06 AC 203 ms
68,444 KB
testcase_07 AC 331 ms
70,496 KB
testcase_08 AC 280 ms
72,544 KB
testcase_09 AC 353 ms
79,872 KB
testcase_10 AC 268 ms
78,552 KB
testcase_11 AC 769 ms
85,588 KB
testcase_12 AC 502 ms
82,308 KB
testcase_13 AC 238 ms
77,952 KB
testcase_14 AC 1,334 ms
130,800 KB
testcase_15 AC 463 ms
103,324 KB
testcase_16 AC 1,797 ms
156,012 KB
testcase_17 AC 1,574 ms
179,828 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

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+1):
    dp.append([-1]*(V+1))

dp[0][0] = 0

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

            tmp = (V-ii)//vs[i] #買える個数

            for iii in range(tmp,0,-1):
                tmp2 = ii+(iii*vs[i])
                dp[i+1][tmp2] = max(dp[i+1][tmp2],dp[i][ii]+(ws[i]*iii+C))

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

print(ans)
0