結果

問題 No.1947 質より種類数
ユーザー titan23titan23
提出日時 2022-07-03 03:18:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,008 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 86,604 KB
実行使用メモリ 274,616 KB
最終ジャッジ日時 2023-08-18 22:24:14
合計ジャッジ時間 13,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,264 KB
testcase_01 AC 68 ms
71,000 KB
testcase_02 AC 62 ms
71,304 KB
testcase_03 AC 64 ms
70,948 KB
testcase_04 AC 90 ms
76,208 KB
testcase_05 AC 84 ms
75,976 KB
testcase_06 AC 92 ms
76,504 KB
testcase_07 AC 87 ms
75,872 KB
testcase_08 AC 83 ms
75,844 KB
testcase_09 AC 103 ms
80,788 KB
testcase_10 AC 94 ms
76,640 KB
testcase_11 AC 130 ms
86,700 KB
testcase_12 AC 121 ms
83,184 KB
testcase_13 AC 94 ms
76,372 KB
testcase_14 AC 329 ms
132,740 KB
testcase_15 AC 191 ms
105,044 KB
testcase_16 AC 489 ms
155,240 KB
testcase_17 AC 452 ms
177,684 KB
testcase_18 AC 1,008 ms
263,632 KB
testcase_19 AC 761 ms
239,752 KB
testcase_20 AC 512 ms
199,784 KB
testcase_21 AC 792 ms
221,400 KB
testcase_22 AC 116 ms
84,840 KB
testcase_23 AC 361 ms
132,408 KB
testcase_24 AC 84 ms
76,180 KB
testcase_25 AC 84 ms
75,796 KB
testcase_26 AC 82 ms
75,828 KB
testcase_27 AC 82 ms
75,964 KB
testcase_28 AC 88 ms
76,440 KB
testcase_29 AC 973 ms
274,568 KB
testcase_30 AC 750 ms
274,568 KB
testcase_31 AC 62 ms
71,024 KB
testcase_32 AC 61 ms
70,948 KB
testcase_33 AC 72 ms
75,772 KB
testcase_34 AC 731 ms
274,488 KB
testcase_35 AC 524 ms
274,376 KB
testcase_36 AC 743 ms
274,616 KB
権限があれば一括ダウンロードができます

ソースコード

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 = [[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