結果

問題 No.1947 質より種類数
ユーザー tassei903tassei903
提出日時 2022-05-21 09:20:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 630 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 76,464 KB
最終ジャッジ日時 2023-10-20 15:43:50
合計ジャッジ時間 8,376 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,544 KB
testcase_01 AC 33 ms
53,544 KB
testcase_02 AC 34 ms
53,544 KB
testcase_03 AC 34 ms
53,544 KB
testcase_04 AC 57 ms
66,108 KB
testcase_05 AC 49 ms
66,104 KB
testcase_06 AC 50 ms
66,104 KB
testcase_07 AC 52 ms
66,104 KB
testcase_08 AC 53 ms
66,108 KB
testcase_09 AC 62 ms
66,104 KB
testcase_10 AC 58 ms
66,104 KB
testcase_11 AC 74 ms
68,496 KB
testcase_12 AC 69 ms
66,104 KB
testcase_13 AC 57 ms
66,104 KB
testcase_14 AC 235 ms
73,588 KB
testcase_15 AC 135 ms
70,768 KB
testcase_16 AC 301 ms
73,588 KB
testcase_17 AC 231 ms
74,112 KB
testcase_18 AC 630 ms
76,464 KB
testcase_19 AC 331 ms
76,392 KB
testcase_20 AC 292 ms
74,640 KB
testcase_21 AC 492 ms
75,096 KB
testcase_22 AC 68 ms
68,508 KB
testcase_23 AC 210 ms
73,584 KB
testcase_24 AC 54 ms
66,100 KB
testcase_25 AC 52 ms
66,104 KB
testcase_26 AC 56 ms
64,040 KB
testcase_27 AC 61 ms
64,040 KB
testcase_28 AC 58 ms
64,040 KB
testcase_29 AC 487 ms
74,660 KB
testcase_30 AC 411 ms
74,572 KB
testcase_31 AC 38 ms
53,544 KB
testcase_32 AC 38 ms
53,544 KB
testcase_33 AC 50 ms
61,952 KB
testcase_34 AC 543 ms
76,432 KB
testcase_35 AC 273 ms
70,924 KB
testcase_36 AC 426 ms
74,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n,V,c = na()
w,v = zip(*[na() for i in range(n)])

dp = [0 for i in range(V+1)]
for i in range(n):

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

    #print(dp)
print(dp[-1])
0