結果

問題 No.1947 質より種類数
ユーザー ikomaikoma
提出日時 2022-05-20 23:13:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 685 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 78,784 KB
最終ジャッジ日時 2023-10-20 14:06:19
合計ジャッジ時間 8,469 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,560 KB
testcase_01 AC 40 ms
53,560 KB
testcase_02 AC 40 ms
53,560 KB
testcase_03 AC 39 ms
53,560 KB
testcase_04 AC 73 ms
72,656 KB
testcase_05 AC 66 ms
70,576 KB
testcase_06 AC 74 ms
73,200 KB
testcase_07 AC 71 ms
72,652 KB
testcase_08 AC 71 ms
72,668 KB
testcase_09 AC 100 ms
75,756 KB
testcase_10 AC 95 ms
75,748 KB
testcase_11 AC 126 ms
76,020 KB
testcase_12 AC 105 ms
75,748 KB
testcase_13 AC 85 ms
75,748 KB
testcase_14 AC 289 ms
76,940 KB
testcase_15 AC 206 ms
76,340 KB
testcase_16 AC 404 ms
77,292 KB
testcase_17 AC 476 ms
77,340 KB
testcase_18 AC 489 ms
78,784 KB
testcase_19 AC 685 ms
77,860 KB
testcase_20 AC 415 ms
77,584 KB
testcase_21 AC 490 ms
77,788 KB
testcase_22 AC 103 ms
75,760 KB
testcase_23 AC 268 ms
76,996 KB
testcase_24 AC 70 ms
72,664 KB
testcase_25 AC 69 ms
70,588 KB
testcase_26 AC 66 ms
68,552 KB
testcase_27 AC 66 ms
70,588 KB
testcase_28 AC 72 ms
73,204 KB
testcase_29 AC 457 ms
78,484 KB
testcase_30 AC 401 ms
78,484 KB
testcase_31 AC 39 ms
53,576 KB
testcase_32 AC 39 ms
53,576 KB
testcase_33 AC 48 ms
62,288 KB
testcase_34 AC 405 ms
78,576 KB
testcase_35 AC 221 ms
78,400 KB
testcase_36 AC 392 ms
77,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


N,V,C=map(int,input().split())
VW=[list(map(int,input().split())) for _ in range(N)]
INF=float("inf")

dp = [-INF]*(V+1)
dp[0]=0
for v,w in VW:
    dp2 = [-INF]*(V+1)
    dp2[0] = 0
    for i in range(V+1):
        dp2[i] = dp[i]
        if i-v>=0:
            dp2[i] = max(dp2[i], dp[i-v]+w+C, dp2[i-v]+w)
    dp = dp2
print(max(dp))
0