結果

問題 No.1947 質より種類数
ユーザー titan23titan23
提出日時 2022-07-03 02:25:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 582 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 263,012 KB
最終ジャッジ日時 2023-08-18 19:42:17
合計ジャッジ時間 27,779 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,260 KB
testcase_01 AC 70 ms
71,024 KB
testcase_02 AC 68 ms
71,252 KB
testcase_03 AC 73 ms
71,296 KB
testcase_04 AC 266 ms
76,296 KB
testcase_05 AC 243 ms
76,024 KB
testcase_06 AC 228 ms
76,816 KB
testcase_07 AC 263 ms
76,228 KB
testcase_08 AC 288 ms
76,304 KB
testcase_09 AC 316 ms
81,228 KB
testcase_10 AC 195 ms
79,832 KB
testcase_11 AC 427 ms
87,056 KB
testcase_12 AC 309 ms
83,448 KB
testcase_13 AC 175 ms
76,288 KB
testcase_14 AC 722 ms
132,536 KB
testcase_15 AC 403 ms
105,072 KB
testcase_16 AC 1,009 ms
154,948 KB
testcase_17 AC 1,295 ms
177,404 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 186 ms
85,192 KB
testcase_23 AC 804 ms
141,784 KB
testcase_24 AC 572 ms
76,096 KB
testcase_25 AC 536 ms
76,128 KB
testcase_26 AC 306 ms
76,092 KB
testcase_27 AC 381 ms
76,172 KB
testcase_28 AC 578 ms
77,908 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

#  -----------------------  #

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

dp = [[-1]*(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):
    if dp[i][j] == -1:
      continue

    dp[i+1][j] = max(dp[i+1][j], dp[i][j])

    if j+v < V+1:
      dp[i+1][j+v] = max(dp[i+1][j+v], dp[i][j]+w+C)
    cnt = 2
    while j+v*cnt < V+1:
      dp[i+1][j+v*cnt] = max(dp[i+1][j+v*cnt], dp[i][j]+w*cnt+C)
      cnt += 1

print(max(dp[n]))
0