結果

問題 No.1947 質より種類数
ユーザー AkariAkari
提出日時 2022-05-20 23:40:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 554 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 11,856 KB
実行使用メモリ 15,176 KB
最終ジャッジ日時 2023-10-20 14:36:44
合計ジャッジ時間 7,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
14,500 KB
testcase_01 AC 27 ms
10,152 KB
testcase_02 AC 27 ms
10,152 KB
testcase_03 AC 26 ms
10,152 KB
testcase_04 AC 105 ms
10,764 KB
testcase_05 AC 79 ms
10,820 KB
testcase_06 AC 84 ms
10,636 KB
testcase_07 AC 90 ms
10,820 KB
testcase_08 AC 112 ms
10,740 KB
testcase_09 AC 353 ms
10,836 KB
testcase_10 AC 247 ms
10,836 KB
testcase_11 AC 780 ms
10,836 KB
testcase_12 AC 533 ms
10,836 KB
testcase_13 AC 206 ms
10,836 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys




def main():
    n, v, c = map(int, input().split())
    dp0 = [0] * (v + 1)
    dp1 = [0] * (v + 1)
    for i in range(n):
        p0 = dp0[:]
        p1 = dp1[:]
        dp0 = [max(p0[j], p1[j]) for j in range(v + 1)]
        dp1 = [0] * (v + 1)
        a, b = map(int, input().split())
        for j in range(a, v + 1):
            dp1[j] = max(dp0[j - a] + b + c, dp1[j - a] + b)
    ans = 0
    for i in range(v + 1):
        ans = max(ans, dp0[i])
        ans = max(ans, dp1[i])
    print(ans)



if __name__ == '__main__':
    main()
0