結果

問題 No.1947 質より種類数
ユーザー mkawa2mkawa2
提出日時 2022-05-20 23:22:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,163 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 284,708 KB
最終ジャッジ日時 2023-10-20 14:14:03
合計ジャッジ時間 11,839 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,596 KB
testcase_01 AC 36 ms
53,576 KB
testcase_02 AC 40 ms
53,576 KB
testcase_03 AC 39 ms
53,576 KB
testcase_04 AC 63 ms
68,548 KB
testcase_05 WA -
testcase_06 AC 61 ms
68,564 KB
testcase_07 AC 63 ms
68,548 KB
testcase_08 AC 65 ms
70,612 KB
testcase_09 AC 103 ms
85,292 KB
testcase_10 AC 78 ms
73,028 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 76 ms
72,660 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n, V, c = LI()

dp = [[0]*(n+1) for _ in range(V+1)]
mx = [[0]*(n+1) for _ in range(V+1)]
vw = LLI(n)

for i in range(1, V+1):
    for j, (v, w) in enumerate(vw,1):
        if i-v < 0: continue
        dp[i][j] = dp[i-v][j]+w
        if j:
            dp[i][j] = max(dp[i][j], mx[i-v][j-1]+w+c)
            mx[i][j] = max(dp[i][j], mx[i][j-1])
        else:
            mx[i][j] = dp[i][j]
# p2D(dp)
# p2D(mx)

ans = mx[-1][-1]
print(ans)
0