結果
| 問題 | No.2093 Shio Ramen |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-10-20 03:17:39 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 123 ms / 2,000 ms |
| + 202µs | |
| コード長 | 742 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 84,736 KB |
| 最終ジャッジ日時 | 2026-07-15 19:32:41 |
| 合計ジャッジ時間 | 5,142 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
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)
norioc