結果
| 問題 | No.921 ずんだアロー |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-07-20 01:50:10 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 222 ms / 2,000 ms |
| + 474µs | |
| コード長 | 737 bytes |
| 記録 | |
| コンパイル時間 | 226 ms |
| コンパイル使用メモリ | 96,088 KB |
| 実行使用メモリ | 97,980 KB |
| 最終ジャッジ日時 | 2026-07-20 01:50:16 |
| 合計ジャッジ時間 | 5,218 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
def accum_dp(xs: list, f, op, e, init: dict):
dp = init.copy()
for x in xs:
pp = {}
dp, pp = pp, dp
for fm_key, fm_val in pp.items():
for to_key, to_val in f(fm_key, fm_val, x):
dp[to_key] = op(dp.get(to_key, e), to_val)
return dp
def f(k, v, x):
# k : 餅の大きさ
match k:
case -1: # 普通の餅
yield -1, v
yield x, v+1 # ずんだ餅
case _:
yield -1, v
if k == x:
yield k, v+1
else:
yield max(k, x), v
N = int(input())
A = list(map(int, input().split()))
init = {-1: 0}
dp = accum_dp(A, f, max, 0, init)
ans = max(dp.values())
print(ans)
norioc