Loading

[SDOI2012] 任务安排

前言

颓颓頽, 哎大家怎么都卷飞了

事已至此, 接着打

思路

首先容易考虑到 \(\rm{dp}\)
考虑令 \(f_i\) 表示解决了前 \(i\) 个任务的最小费用
你发现直接转移是 \(\mathcal{O} (n^3)\) 的, 需要进一步优化
考虑费用提前计算, 当前的分组 \([L, R]\) 对后面的花费影响是 \(\displaystyle s \times \sum_{i = L}^{n} C_i + \sum_{i = 1}^{n} T_i \times \sum_{i = L}^{R} C_i\)
据此写出转移方程,

\[f_i \gets \min_{j = 0}^{i - 1} f_j + s \times \textrm{suf}_i + \textrm{pre}_i \times (\textrm{suf}_i - \textrm{suf}_j) \]

考虑拆一下这个柿子

\[\begin{align*} & f_j + s \cdot \textrm{suf}_i + \textrm{pre}_i(\textrm{suf}_i - \textrm{suf}_j) \\ =& s \cdot \textrm{suf}_i + \textrm{pre}_i \cdot \textrm{suf}_i + f_j - \textrm{pre}_i \cdot \textrm{suf}_j \end{align*} \]

简单的化一下
首先令 \(w_i = s \cdot \textrm{suf}_i + \textrm{pre}_i \cdot \textrm{suf}_i\)

\[f_i \gets w_i + \min_{j = 0}^{i - 1} f_j - \textrm{pre}_i \cdot \textrm{suf}_j \]

很经典的斜率优化, 不在赘述

总结

费用提前计算可以省去一维, 常见的模型: 时间叠加

posted @ 2025-01-10 15:44  Yorg  阅读(13)  评论(0)    收藏  举报