QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: LastKismet

Posted at: 2026-08-18 21:04:34

Last updated: 2026-08-18 21:04:43

Back to Problem

New Editorial for Problem #9220

你买票的时间必然是恰好停在某个站的时间,容易有一个 DP $f(i,x)$ 表示考虑到第 $i$ 个站,花费 $x$ 元最远能到达的超过 $a_i$ 的距离,注意到记 $x_0$ 为首个 $f(i,x)\ge a_i$ 的 $x$,那么有效的 $x$ 只有 $x_0,x_0+1,x_0+2$,更大的 $x$ 不优。

对此计数,容易有一个 $F(i,x,f(i,x),f(i,x+1),f(i,x+2))$,转移就 $F(i,x)\to F(i,x)$ 或者 $F(i,x)\to F(i,x+1)$。考虑优化,首先扔掉 $x$ 维度,转移 $F(i,x)\to F(i,x+1)$ 时给答案加上产生的 $\delta=1$ 乘可能方案数即可。然后你后面三个维度转而维护 $f(i,x)-a_i$ ,该值不超过 $75$,就做完了。

Comments

No comments yet.