結果

問題 No.2232 Miser's Gift
ユーザー tktk_snsntktk_snsn
提出日時 2023-03-03 21:28:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 1,253 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 81,472 KB
実行使用メモリ 80,464 KB
最終ジャッジ日時 2023-10-18 01:22:28
合計ジャッジ時間 9,897 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
73,356 KB
testcase_01 AC 74 ms
73,356 KB
testcase_02 AC 75 ms
73,356 KB
testcase_03 AC 138 ms
80,408 KB
testcase_04 AC 115 ms
80,344 KB
testcase_05 AC 101 ms
79,636 KB
testcase_06 AC 74 ms
73,356 KB
testcase_07 AC 103 ms
80,464 KB
testcase_08 AC 149 ms
80,344 KB
testcase_09 AC 151 ms
80,344 KB
testcase_10 AC 149 ms
80,340 KB
testcase_11 AC 151 ms
80,340 KB
testcase_12 AC 152 ms
80,344 KB
testcase_13 AC 141 ms
80,408 KB
testcase_14 AC 139 ms
80,336 KB
testcase_15 AC 140 ms
80,412 KB
testcase_16 AC 140 ms
80,336 KB
testcase_17 AC 144 ms
80,416 KB
testcase_18 AC 138 ms
80,340 KB
testcase_19 AC 140 ms
80,332 KB
testcase_20 AC 140 ms
80,336 KB
testcase_21 AC 140 ms
80,332 KB
testcase_22 AC 141 ms
80,408 KB
testcase_23 AC 174 ms
80,344 KB
testcase_24 AC 174 ms
80,336 KB
testcase_25 AC 173 ms
80,340 KB
testcase_26 AC 177 ms
80,344 KB
testcase_27 AC 177 ms
80,336 KB
testcase_28 AC 142 ms
80,344 KB
testcase_29 AC 142 ms
80,344 KB
testcase_30 AC 141 ms
80,340 KB
testcase_31 AC 147 ms
80,340 KB
testcase_32 AC 142 ms
80,344 KB
testcase_33 AC 140 ms
80,340 KB
testcase_34 AC 140 ms
80,332 KB
testcase_35 AC 140 ms
80,408 KB
testcase_36 AC 141 ms
80,408 KB
testcase_37 AC 141 ms
80,408 KB
testcase_38 AC 94 ms
79,016 KB
testcase_39 AC 95 ms
79,020 KB
testcase_40 AC 94 ms
79,024 KB
testcase_41 AC 94 ms
79,016 KB
testcase_42 AC 93 ms
79,020 KB
testcase_43 AC 94 ms
79,020 KB
testcase_44 AC 93 ms
79,020 KB
testcase_45 AC 94 ms
79,020 KB
testcase_46 AC 94 ms
79,020 KB
testcase_47 AC 94 ms
79,024 KB
testcase_48 AC 78 ms
74,344 KB
testcase_49 AC 77 ms
74,032 KB
testcase_50 AC 78 ms
74,332 KB
testcase_51 AC 81 ms
74,328 KB
testcase_52 AC 79 ms
74,332 KB
testcase_53 AC 79 ms
74,352 KB
testcase_54 AC 77 ms
74,336 KB
testcase_55 AC 79 ms
74,332 KB
testcase_56 AC 80 ms
74,344 KB
testcase_57 AC 78 ms
74,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import os
import inspect
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 18

if os.getenv("TKTKLOCAL", False):
    def debug(*arg, sep=" ", end="\n"):
        print(*arg, sep=sep, end=end, file=sys.stderr)

    def debug_indent(*arg, sep=" ", end="\n", indent="    "):
        frame = inspect.currentframe().f_back
        par_func = inspect.getframeinfo(frame).function
        if par_func == "<module>":
            debug(*arg, sep=sep, end=end)
            return

        frame_stack = inspect.stack()
        if len(frame_stack) > 30:
            return

        depth = sum(f.function == par_func for f in frame_stack)
        debug(indent * (depth - 1), end="")
        debug(*arg, sep=sep, end=end)
else:
    def debug(*arg, **kwarg):
        pass

    def debug_indent(*arg, **kwarg):
        pass


def main():
    N, W = map(int, input().split())
    dp = [-inf] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for i in range(a, W+1)[::-1]:
            dp[i] = max(dp[i], dp[i-a] + b)

    debug(dp)
    for i in range(1, W+1):
        dp[i] = max(dp[i], dp[i-1])

    wmax = dp[W] + 1
    for i in range(1, W+1):
        print(wmax - dp[W - i])


main()
0