結果

問題 No.1947 質より種類数
ユーザー ronpooronpoo
提出日時 2023-11-21 16:47:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,516 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 431,288 KB
最終ジャッジ日時 2023-11-21 16:47:52
合計ジャッジ時間 15,599 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,332 KB
testcase_01 AC 36 ms
53,332 KB
testcase_02 AC 36 ms
53,332 KB
testcase_03 AC 36 ms
53,332 KB
testcase_04 AC 75 ms
73,032 KB
testcase_05 AC 68 ms
73,056 KB
testcase_06 AC 81 ms
76,516 KB
testcase_07 AC 72 ms
73,188 KB
testcase_08 AC 75 ms
74,464 KB
testcase_09 AC 103 ms
80,004 KB
testcase_10 AC 98 ms
78,644 KB
testcase_11 AC 163 ms
86,028 KB
testcase_12 AC 121 ms
82,516 KB
testcase_13 AC 90 ms
78,140 KB
testcase_14 AC 453 ms
178,420 KB
testcase_15 AC 311 ms
116,480 KB
testcase_16 AC 600 ms
225,304 KB
testcase_17 AC 711 ms
284,204 KB
testcase_18 AC 1,516 ms
431,288 KB
testcase_19 AC 1,328 ms
337,048 KB
testcase_20 AC 915 ms
314,432 KB
testcase_21 AC 1,049 ms
338,784 KB
testcase_22 AC 127 ms
83,888 KB
testcase_23 AC 600 ms
200,316 KB
testcase_24 AC 73 ms
73,028 KB
testcase_25 AC 68 ms
73,040 KB
testcase_26 AC 64 ms
70,976 KB
testcase_27 AC 68 ms
70,968 KB
testcase_28 AC 74 ms
73,844 KB
testcase_29 AC 1,077 ms
417,276 KB
testcase_30 AC 1,001 ms
417,276 KB
testcase_31 AC 37 ms
53,332 KB
testcase_32 AC 36 ms
53,332 KB
testcase_33 AC 47 ms
62,096 KB
testcase_34 AC 793 ms
415,740 KB
testcase_35 AC 700 ms
420,476 KB
testcase_36 AC 1,025 ms
419,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[-float('inf')] * (M+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    v, w = VW[i]
    for j in range(M+1):
        if j + v <= M:
            dp[i+1][j+v] = max(dp[i+1][j+v], dp[i+1][j] + w, dp[i][j] + w + C)
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
ans = max(dp[N])
print(ans)
0