[BZOJ1575] [Usaco2009 Jan]气象牛Baric(DP)


传送门

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; }

  



上一篇:[BZOJ3378] [Usaco2004 Open]MooFest 狂欢节(树状数组)

下一篇:[BZOJ4756] [Usaco2017 Jan]Promotion Counting(线段树合并)


DP
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图