题解:AT_abc288_e [ABC288E] Wish List

· · 题解

考虑 DP。

转移分两类,即 $i$ 是否为想要的物品。通过预处理 $s_{i,j} = \min \limits_{x=i}^j c_x$ 可以 $O(1)$ 转移,故总复杂度 $O(n^2)$。