結果

問題 No.1947 質より種類数
ユーザー titan23titan23
提出日時 2022-07-03 02:25:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 582 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 324,096 KB
最終ジャッジ日時 2024-11-28 03:19:05
合計ジャッジ時間 30,412 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
57,472 KB
testcase_01 AC 42 ms
323,968 KB
testcase_02 AC 43 ms
57,088 KB
testcase_03 AC 47 ms
324,096 KB
testcase_04 AC 240 ms
73,216 KB
testcase_05 AC 231 ms
67,328 KB
testcase_06 AC 210 ms
70,528 KB
testcase_07 AC 243 ms
67,712 KB
testcase_08 AC 269 ms
67,968 KB
testcase_09 AC 291 ms
72,832 KB
testcase_10 AC 176 ms
71,040 KB
testcase_11 AC 423 ms
85,888 KB
testcase_12 AC 301 ms
81,920 KB
testcase_13 AC 161 ms
70,272 KB
testcase_14 AC 729 ms
131,456 KB
testcase_15 AC 399 ms
103,936 KB
testcase_16 AC 1,037 ms
156,032 KB
testcase_17 AC 1,329 ms
177,920 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 1,976 ms
198,784 KB
testcase_21 TLE -
testcase_22 AC 156 ms
83,328 KB
testcase_23 AC 722 ms
133,632 KB
testcase_24 AC 509 ms
68,224 KB
testcase_25 AC 460 ms
67,328 KB
testcase_26 AC 253 ms
65,408 KB
testcase_27 AC 317 ms
66,176 KB
testcase_28 AC 508 ms
71,552 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 AC 40 ms
51,712 KB
testcase_32 AC 38 ms
51,456 KB
testcase_33 AC 114 ms
61,568 KB
testcase_34 AC 1,075 ms
272,768 KB
testcase_35 AC 361 ms
272,384 KB
testcase_36 TLE -
権限があれば一括ダウンロードができます

ソースコード

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