結果

問題 No.1947 質より種類数
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-05-21 18:18:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 753 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 79,068 KB
最終ジャッジ日時 2023-10-20 16:29:44
合計ジャッジ時間 9,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,488 KB
testcase_01 AC 37 ms
53,488 KB
testcase_02 AC 38 ms
53,488 KB
testcase_03 AC 37 ms
53,488 KB
testcase_04 AC 77 ms
68,364 KB
testcase_05 AC 60 ms
68,372 KB
testcase_06 AC 61 ms
68,388 KB
testcase_07 AC 61 ms
68,364 KB
testcase_08 AC 65 ms
70,456 KB
testcase_09 AC 81 ms
75,544 KB
testcase_10 AC 71 ms
72,464 KB
testcase_11 AC 112 ms
76,020 KB
testcase_12 AC 92 ms
75,604 KB
testcase_13 AC 69 ms
72,472 KB
testcase_14 AC 292 ms
76,996 KB
testcase_15 AC 174 ms
76,244 KB
testcase_16 AC 375 ms
77,416 KB
testcase_17 AC 449 ms
77,876 KB
testcase_18 AC 753 ms
78,832 KB
testcase_19 AC 655 ms
78,480 KB
testcase_20 AC 520 ms
77,940 KB
testcase_21 AC 592 ms
78,176 KB
testcase_22 AC 93 ms
75,972 KB
testcase_23 AC 323 ms
77,144 KB
testcase_24 AC 63 ms
70,408 KB
testcase_25 AC 62 ms
68,304 KB
testcase_26 AC 57 ms
66,236 KB
testcase_27 AC 61 ms
68,308 KB
testcase_28 AC 69 ms
70,404 KB
testcase_29 AC 492 ms
78,820 KB
testcase_30 AC 437 ms
78,984 KB
testcase_31 AC 37 ms
53,488 KB
testcase_32 AC 37 ms
53,488 KB
testcase_33 AC 51 ms
64,164 KB
testcase_34 AC 750 ms
79,068 KB
testcase_35 AC 341 ms
78,828 KB
testcase_36 AC 435 ms
79,020 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