結果

問題 No.2093 Shio Ramen
ユーザー 👑 tamatotamato
提出日時 2022-10-07 21:26:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 77,380 KB
最終ジャッジ日時 2023-09-02 23:56:48
合計ジャッジ時間 4,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,388 KB
testcase_01 AC 64 ms
71,436 KB
testcase_02 AC 64 ms
71,348 KB
testcase_03 AC 65 ms
71,064 KB
testcase_04 AC 67 ms
71,420 KB
testcase_05 AC 67 ms
71,400 KB
testcase_06 AC 63 ms
71,360 KB
testcase_07 AC 66 ms
71,356 KB
testcase_08 AC 66 ms
71,292 KB
testcase_09 AC 80 ms
76,484 KB
testcase_10 AC 83 ms
76,304 KB
testcase_11 AC 73 ms
75,684 KB
testcase_12 AC 80 ms
76,444 KB
testcase_13 AC 76 ms
76,656 KB
testcase_14 AC 79 ms
76,152 KB
testcase_15 AC 85 ms
76,272 KB
testcase_16 AC 78 ms
76,468 KB
testcase_17 AC 79 ms
76,812 KB
testcase_18 AC 93 ms
77,028 KB
testcase_19 AC 87 ms
76,500 KB
testcase_20 AC 82 ms
76,308 KB
testcase_21 AC 85 ms
76,328 KB
testcase_22 AC 86 ms
76,444 KB
testcase_23 AC 87 ms
77,380 KB
testcase_24 AC 97 ms
77,028 KB
testcase_25 AC 90 ms
77,204 KB
testcase_26 AC 93 ms
76,928 KB
testcase_27 AC 93 ms
76,948 KB
testcase_28 AC 90 ms
76,952 KB
testcase_29 AC 88 ms
77,036 KB
testcase_30 AC 91 ms
77,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
inf = 10 ** 17


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    SA = []
    for _ in range(N):
        SA.append(tuple(map(int, input().split())))

    dp = [-inf] * (K + 1)
    dp[0] = 0
    for s, a in SA:
        dp_new = [-inf] * (K + 1)
        for j in range(K + 1):
            dp_new[j] = max(dp_new[j], dp[j])
            if j + s <= K:
                dp_new[j + s] = max(dp_new[j + s], dp[j] + a)
        dp = dp_new
    ans = 0
    for j in range(K+1):
        ans = max(ans, dp[j])
    print(ans)


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