动态规划训练20 [Treats for the Cows POJ
来源:互联网 发布:时代周刊封面 知乎ps 编辑:程序博客网 时间:2024/06/08 11:51
Treats for the Cows
POJ - 3186简单的区间DP,就不解释了。
#include<iostream>#include<cstdio>using namespace std;const int INF=1e9;const int maxn=2005;int n, a[maxn];int dp[maxn][maxn];int main() { scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",a+i); for(int i=0;i<n;i++) dp[i][i]=n*a[i]; for(int i=1;i<n;i++) { for(int j=0;j<n-i;j++) { dp[j][j+i]=max(dp[j][j+i-1]+(n-i)*a[j+i],dp[j+1][j+i]+(n-i)*a[j]); } } printf("%d\n",dp[0][n-1]); return 0;}
阅读全文
0 0
- 动态规划训练20 [Treats for the Cows POJ
- O - Treats for the Cows POJ 3186 ( 动态规划+区间 )
- poj 3186 Treats for the Cows 动态规划
- POJ-3186-Treats for the Cows-动态规划DP
- Treats for the Cows POJ
- 【动态规划】[luoguP2858 USACO06FEB]奶牛零食Treats for the Cows
- POJ 3186 Treats for the Cows
- poj(3186)Treats for the Cows
- poj 3186 Treats for the Cows
- POJ 3186 Treats for the Cows
- POJ 3186 Treats for the Cows
- POJ 3186 Treats for the Cows (DP)
- POJ 3186 Treats for the Cows
- POJ 3186 Treats for the Cows
- POJ 3166 Treats for the Cows
- POJ 3186Treats for the Cows
- POJ-3186-Treats for the Cows
- POJ - 3186----Treats for the Cows
- 学习python challenge 7
- UTF-8, Unicode, GB2312格式串转换之C语言版
- 近5年133个Java面试题 你会几个?
- npm的安装及Vue.js2.0从入门到放弃---入门实例(一)
- C
- 动态规划训练20 [Treats for the Cows POJ
- BFS练习-POJ.2386
- MySQL性能优化的最佳21条经验
- 圆环取数
- 什么是SVM? 写得挺有意思
- “玲珑杯”线上赛 Round #17 Sin your life(数学知识)
- 动态规划训练21 [FatMouse and Cheese HDU
- 管道
- 线程基础概念