結果

問題 No.1947 質より種類数
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-20 23:34:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 101,696 KB
最終ジャッジ日時 2023-10-20 14:31:03
合計ジャッジ時間 8,086 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,540 KB
testcase_01 AC 33 ms
53,540 KB
testcase_02 AC 31 ms
53,540 KB
testcase_03 AC 36 ms
53,540 KB
testcase_04 AC 52 ms
73,384 KB
testcase_05 WA -
testcase_06 AC 54 ms
74,128 KB
testcase_07 AC 47 ms
70,588 KB
testcase_08 AC 56 ms
70,580 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 109 ms
76,004 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 63 ms
72,632 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 52 ms
72,660 KB
testcase_29 AC 768 ms
85,056 KB
testcase_30 WA -
testcase_31 AC 32 ms
53,540 KB
testcase_32 AC 32 ms
53,540 KB
testcase_33 WA -
testcase_34 AC 44 ms
64,576 KB
testcase_35 AC 40 ms
62,332 KB
testcase_36 AC 1,097 ms
101,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 10

N, V, C = map(int, input().split())
dp = [-inf] * (V + 1)
dp[0] = 0
for _ in range(N):
    v, w = map(int, input().split())
    memo = set()
    for i in range(v, V+1):
        if i - v in memo:
            if dp[i] < dp[i-v] + w:
                memo.add(i)
                dp[i] = dp[i-v] + w
        else:
            if dp[i] < dp[i-v] + w + C:
                memo.add(i)
                dp[i] = dp[i-v] + w + C

print(max(dp))
0