QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: jiangly

Posted at: 2025-12-13 00:12:19

Last updated: 2025-12-13 00:12:24

Back to Problem

题解

如果 $a_i\le a_{i+1}$,显然 $i$ 不影响答案,于是可以转化为 $a_i>a_{i+1}$ 的情形。

设 $f(i)$ 为前 $i$ 个人的最早结束时间,则有 $$ f(i)=\min_{0\le j < i}\{\max\{f(j),t_i\}+2a_{j+1}\} $$ 显然 $f(i)$ 是不减的,因此对于 $f(j)$ 和 $t_i$ 的大小关系分别讨论,分别用前缀 $\min$ 和单调队列维护即可。

时间复杂度 $O(n)$。

Comments

No comments yet.