結果

問題 No.1947 質より種類数
ユーザー nephrologistnephrologist
提出日時 2022-05-23 04:49:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 405 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 77,724 KB
最終ジャッジ日時 2023-10-20 17:26:04
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,480 KB
testcase_01 AC 34 ms
53,480 KB
testcase_02 AC 32 ms
53,480 KB
testcase_03 AC 33 ms
53,480 KB
testcase_04 AC 60 ms
68,288 KB
testcase_05 AC 48 ms
66,212 KB
testcase_06 AC 51 ms
68,296 KB
testcase_07 AC 49 ms
66,212 KB
testcase_08 AC 50 ms
68,276 KB
testcase_09 AC 62 ms
73,900 KB
testcase_10 AC 57 ms
72,384 KB
testcase_11 AC 77 ms
75,904 KB
testcase_12 AC 69 ms
75,484 KB
testcase_13 AC 53 ms
70,336 KB
testcase_14 AC 163 ms
76,252 KB
testcase_15 AC 94 ms
76,124 KB
testcase_16 AC 214 ms
76,612 KB
testcase_17 AC 183 ms
76,640 KB
testcase_18 AC 405 ms
77,100 KB
testcase_19 AC 383 ms
76,924 KB
testcase_20 AC 205 ms
76,816 KB
testcase_21 AC 329 ms
77,300 KB
testcase_22 AC 67 ms
75,948 KB
testcase_23 AC 181 ms
76,296 KB
testcase_24 AC 50 ms
68,256 KB
testcase_25 AC 51 ms
66,148 KB
testcase_26 AC 47 ms
66,148 KB
testcase_27 AC 49 ms
66,132 KB
testcase_28 AC 55 ms
68,228 KB
testcase_29 AC 254 ms
77,660 KB
testcase_30 AC 266 ms
77,672 KB
testcase_31 AC 33 ms
53,480 KB
testcase_32 AC 31 ms
53,480 KB
testcase_33 AC 41 ms
62,004 KB
testcase_34 AC 345 ms
77,724 KB
testcase_35 AC 173 ms
77,004 KB
testcase_36 AC 264 ms
77,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

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


# total limit = k としておく(文字がかぶる)

# dp: 重さiまでの最高価値としておく。


dp = [0] * (k + 1)

for _ in range(n):
    w, v = map(int, input().split())
    ndp = [0] * (k + 1)

    for i in range(k + 1):
        # dp[i]+c, ndp[i-v]とmxとればOK
        ndp[i] = max(ndp[i], dp[i])
        if i - w >= 0:
            ndp[i] = max(dp[i - w] + c + v, ndp[i])
            ndp[i] = max(ndp[i], ndp[i - w] + v)
    dp = ndp[:]
    # print("dp", dp)
print(max(dp))
0