結果

問題 No.2093 Shio Ramen
コンテスト
ユーザー norioc
提出日時 2025-10-20 03:17:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 76,784 KB
最終ジャッジ日時 2025-10-20 03:17:44
合計ジャッジ時間 4,200 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections.abc import Iterable


def accum_dp1(xs: Iterable, f, op, e: int, size: int, init: Iterable, *, is_reset=True):
    dp = [e] * size
    for i, v in init:
        dp[i] = v

    for x in xs:
        pp = [e] * size if is_reset else dp.copy()
        dp, pp = pp, dp
        for i in range(size):
            for p, v in f(i, pp[i], x):
                if not (0 <= p < size): continue
                dp[p] = op(dp[p], v)

    return dp


N, I = map(int, input().split())
xs = []
for _ in range(N):
    s, a = map(int, input().split())
    xs.append((s, a))


def f(i, v, x):
    s, a = x  # (塩の濃さ, 味の濃さ)
    return [(i+s, v+a)]


dp = accum_dp1(xs, f, max, 0, I+1, [], is_reset=False)
ans = max(dp)
print(ans)
0