結果

問題 No.1947 質より種類数
ユーザー stngstng
提出日時 2022-05-21 19:04:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 756 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 79,048 KB
最終ジャッジ日時 2023-10-20 16:32:40
合計ジャッジ時間 9,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,468 KB
testcase_01 AC 35 ms
53,468 KB
testcase_02 AC 35 ms
53,468 KB
testcase_03 AC 35 ms
53,468 KB
testcase_04 AC 60 ms
68,324 KB
testcase_05 AC 57 ms
68,328 KB
testcase_06 AC 59 ms
68,344 KB
testcase_07 AC 58 ms
68,320 KB
testcase_08 AC 64 ms
70,412 KB
testcase_09 AC 79 ms
75,628 KB
testcase_10 AC 69 ms
72,420 KB
testcase_11 AC 109 ms
75,980 KB
testcase_12 AC 89 ms
75,564 KB
testcase_13 AC 66 ms
72,436 KB
testcase_14 AC 294 ms
76,928 KB
testcase_15 AC 173 ms
76,212 KB
testcase_16 AC 373 ms
77,348 KB
testcase_17 AC 451 ms
77,844 KB
testcase_18 AC 756 ms
78,836 KB
testcase_19 AC 660 ms
78,448 KB
testcase_20 AC 525 ms
77,908 KB
testcase_21 AC 591 ms
78,144 KB
testcase_22 AC 91 ms
75,900 KB
testcase_23 AC 323 ms
77,104 KB
testcase_24 AC 64 ms
70,380 KB
testcase_25 AC 62 ms
68,276 KB
testcase_26 AC 57 ms
66,208 KB
testcase_27 AC 61 ms
68,280 KB
testcase_28 AC 65 ms
70,376 KB
testcase_29 AC 491 ms
78,768 KB
testcase_30 AC 440 ms
78,948 KB
testcase_31 AC 36 ms
53,476 KB
testcase_32 AC 35 ms
53,476 KB
testcase_33 AC 49 ms
64,136 KB
testcase_34 AC 752 ms
79,048 KB
testcase_35 AC 344 ms
78,824 KB
testcase_36 AC 435 ms
78,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,V,c = map(int,input().split())

vw = [list(map(int,input().split())) for _ in range(n)]
dp = [-1] * (V+1)
dp[0] = 0
for v,w in vw:
    n_dp = [-1] * (V+1)
    for i in range(V+1):
        if dp[i] >= 0:
            if i + v <= V:
                n_dp[i+v] = max(n_dp[i+v],dp[i] + w+c)
    for i in range(V+1):
        if n_dp[i] >= 0:
            if i + v <= V:
                n_dp[i+v] = max(n_dp[i+v],n_dp[i] + w)
    
    for i in range(V+1):
        n_dp[i] = max(dp[i],n_dp[i])
#     print(n_dp)
    dp = n_dp[:]
print(max(dp))
0