結果

問題 No.1947 質より種類数
ユーザー nohakai3nohakai3
提出日時 2022-09-01 19:02:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 423 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 74,496 KB
最終ジャッジ日時 2024-04-26 19:41:41
合計ジャッジ時間 13,023 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
16,128 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 299 ms
13,952 KB
testcase_05 AC 220 ms
12,672 KB
testcase_06 AC 219 ms
13,056 KB
testcase_07 AC 267 ms
12,544 KB
testcase_08 AC 321 ms
13,568 KB
testcase_09 AC 1,209 ms
24,576 KB
testcase_10 AC 856 ms
20,864 KB
testcase_11 TLE -
testcase_12 AC 1,901 ms
26,752 KB
testcase_13 AC 690 ms
17,024 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
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 #

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

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

for i in range(n):
  v, w = vw[i]
  for j in range(V+1):
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])

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

print(max(dp[n]))
0