传送门
DP
f[i][j]表示前i个中选j个的最优解
预处理g[i][j]表示选i~j对答案的贡献
那么就可以n^3乱搞了!
注意边界
#include <cstdio> #include <cstring> #include <iostream> #define N 110 #define abs(x) ((x) < 0 ? (x) : (x)) #define min(x, y) ((x) < (y) ? (x) : (y)) int n, e, ans; int a[N], f[N][N], g[N][N]; inline int read() int main() for(i = 1; i <= n; i++) } return 0; }
上一篇:[BZOJ1572] [Usaco2009 Open]工作安排Job(贪心 + 堆)
下一篇:[BZOJ4756] [Usaco2017 Jan]Promotion Counting(线段树合并)
DP









