結果

問題 No.1947 質より種類数
ユーザー 👑 rin204rin204
提出日時 2022-05-20 21:47:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,568 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2023-10-20 12:15:42
合計ジャッジ時間 6,229 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,328 KB
testcase_01 AC 38 ms
53,328 KB
testcase_02 AC 38 ms
53,328 KB
testcase_03 AC 38 ms
53,328 KB
testcase_04 AC 58 ms
65,756 KB
testcase_05 AC 53 ms
63,684 KB
testcase_06 AC 55 ms
65,764 KB
testcase_07 AC 54 ms
63,684 KB
testcase_08 AC 60 ms
65,756 KB
testcase_09 AC 63 ms
67,792 KB
testcase_10 AC 59 ms
65,744 KB
testcase_11 AC 83 ms
76,200 KB
testcase_12 AC 68 ms
69,840 KB
testcase_13 AC 57 ms
65,744 KB
testcase_14 AC 174 ms
76,192 KB
testcase_15 AC 102 ms
76,048 KB
testcase_16 AC 216 ms
76,276 KB
testcase_17 AC 184 ms
76,416 KB
testcase_18 AC 407 ms
76,672 KB
testcase_19 AC 391 ms
76,592 KB
testcase_20 AC 206 ms
76,512 KB
testcase_21 AC 327 ms
76,116 KB
testcase_22 AC 76 ms
76,144 KB
testcase_23 AC 190 ms
75,856 KB
testcase_24 AC 54 ms
63,684 KB
testcase_25 AC 55 ms
63,696 KB
testcase_26 AC 53 ms
63,688 KB
testcase_27 AC 56 ms
63,688 KB
testcase_28 AC 58 ms
65,764 KB
testcase_29 AC 324 ms
76,344 KB
testcase_30 AC 254 ms
76,344 KB
testcase_31 AC 39 ms
53,328 KB
testcase_32 AC 37 ms
53,328 KB
testcase_33 AC 45 ms
59,548 KB
testcase_34 AC 379 ms
76,348 KB
testcase_35 AC 184 ms
76,288 KB
testcase_36 AC 233 ms
76,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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