結果

問題 No.1947 質より種類数
ユーザー gr1msl3ygr1msl3y
提出日時 2022-05-22 22:23:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2024-09-20 12:56:15
合計ジャッジ時間 6,336 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,840 KB
testcase_01 AC 42 ms
51,840 KB
testcase_02 AC 41 ms
51,840 KB
testcase_03 AC 42 ms
51,968 KB
testcase_04 AC 58 ms
64,128 KB
testcase_05 AC 59 ms
64,256 KB
testcase_06 AC 66 ms
66,048 KB
testcase_07 AC 62 ms
64,128 KB
testcase_08 AC 68 ms
64,000 KB
testcase_09 AC 69 ms
64,640 KB
testcase_10 AC 64 ms
63,872 KB
testcase_11 AC 81 ms
66,432 KB
testcase_12 AC 77 ms
64,896 KB
testcase_13 AC 65 ms
64,640 KB
testcase_14 AC 190 ms
76,800 KB
testcase_15 AC 115 ms
69,376 KB
testcase_16 AC 262 ms
76,672 KB
testcase_17 AC 213 ms
76,928 KB
testcase_18 AC 486 ms
77,696 KB
testcase_19 AC 276 ms
77,440 KB
testcase_20 AC 235 ms
76,800 KB
testcase_21 AC 410 ms
76,800 KB
testcase_22 AC 73 ms
65,792 KB
testcase_23 AC 202 ms
76,928 KB
testcase_24 AC 59 ms
64,256 KB
testcase_25 AC 58 ms
63,360 KB
testcase_26 AC 57 ms
62,848 KB
testcase_27 AC 57 ms
62,976 KB
testcase_28 AC 62 ms
64,640 KB
testcase_29 AC 416 ms
76,928 KB
testcase_30 AC 305 ms
77,824 KB
testcase_31 AC 40 ms
51,840 KB
testcase_32 AC 39 ms
51,968 KB
testcase_33 AC 53 ms
60,928 KB
testcase_34 AC 240 ms
77,440 KB
testcase_35 AC 152 ms
75,264 KB
testcase_36 AC 298 ms
77,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, V, C = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

INF = 10**18
dp = [-INF]*(V+1)
dp[0] = 0

for v, w in A:
    for i in range(V, -1, -1):
        if i+v > V:
            continue
        dp[i+v] = max(dp[i+v], dp[i]+w+C)
    for i in range(V+1):
        if i+v > V:
            break
        dp[i+v] = max(dp[i+v], dp[i]+w)

print(max(dp))
0