結果

問題 No.1947 質より種類数
ユーザー first_vilfirst_vil
提出日時 2022-05-20 22:05:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 76,440 KB
最終ジャッジ日時 2023-10-20 12:46:54
合計ジャッジ時間 6,223 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,420 KB
testcase_01 AC 39 ms
53,420 KB
testcase_02 AC 38 ms
53,420 KB
testcase_03 AC 38 ms
53,420 KB
testcase_04 AC 64 ms
72,388 KB
testcase_05 AC 60 ms
70,324 KB
testcase_06 AC 65 ms
72,400 KB
testcase_07 AC 60 ms
70,316 KB
testcase_08 AC 65 ms
72,388 KB
testcase_09 AC 69 ms
73,644 KB
testcase_10 AC 66 ms
72,376 KB
testcase_11 AC 85 ms
75,972 KB
testcase_12 AC 79 ms
75,472 KB
testcase_13 AC 63 ms
72,376 KB
testcase_14 AC 173 ms
76,040 KB
testcase_15 AC 121 ms
76,016 KB
testcase_16 AC 223 ms
76,116 KB
testcase_17 AC 172 ms
76,152 KB
testcase_18 AC 428 ms
76,324 KB
testcase_19 AC 228 ms
76,284 KB
testcase_20 AC 194 ms
76,196 KB
testcase_21 AC 351 ms
76,252 KB
testcase_22 AC 76 ms
75,976 KB
testcase_23 AC 189 ms
76,056 KB
testcase_24 AC 59 ms
70,312 KB
testcase_25 AC 59 ms
70,328 KB
testcase_26 AC 57 ms
70,312 KB
testcase_27 AC 58 ms
70,316 KB
testcase_28 AC 64 ms
73,112 KB
testcase_29 AC 339 ms
76,432 KB
testcase_30 AC 261 ms
76,436 KB
testcase_31 AC 38 ms
53,420 KB
testcase_32 AC 36 ms
53,420 KB
testcase_33 AC 48 ms
64,120 KB
testcase_34 AC 344 ms
76,440 KB
testcase_35 AC 182 ms
76,124 KB
testcase_36 AC 259 ms
76,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353


def chmax(arr, i, v):
    if arr[i] < v:
        arr[i] = v


n, v, c = mi()
dp = [0] * (v + 1)
for _ in range(n):
    cost, value = mi()
    nxt = dp[:]
    for i in range(v):
        if i + cost <= v:
            chmax(nxt, i + cost, dp[i] + value + c)
            chmax(nxt, i + cost, nxt[i] + value)
        chmax(nxt, i, dp[i])
    dp = nxt
print(max(dp))
0