poj3186 dp
来源:互联网 发布:怎么用jquery遍历数组 编辑:程序博客网 时间:2024/05/24 03:03
/************************************************ *Author :jibancanyang *Created Time :二 4/ 5 09:33:33 2016 *题目类型:*最直观的思维是发现搜索很好写,但是仔细一想是可以转化为递推的.递推的时候要找 *矩阵中的转移路线然后确定递推顺序.本题也是一直二叉树来记忆化逐步优化为递推二维dp的典型例子*************************************************/#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <stack>using namespace std;typedef pair<int, int> pii;typedef long long ll;typedef unsigned long long ull;vector<int> vi;#define xx first#define yy second#define sa(n) scanf("%d", &(n))#define rep(i, a, n) for (int i = a; i < n; i++)#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 2e3 + 12;int a[maxn];int dp[maxn][maxn];int main(void){#ifdef LOCAL //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);#endif int n; while (~sa(n)) { rep (i, 1, n + 1) sa(a[i]), dp[i][i] = a[i] * n; for (int i = n - 1; i > 0; i--) { for (int j = i + 1; j <= n; j++) { int t = n - j + i; dp[i][j] = max(dp[i][j - 1] + t * a[j], dp[i + 1][j] + t * a[i]); } } cout << dp[1][n] << endl; } return 0;}
0 0
- poj3186 dp
- dp poj3186
- POJ3186【区间DP】
- POJ3186迷之DP
- poj3186(区间dp)
- poj3186
- POJ3186
- POJ3186:Treats for the Cows(区间DP)
- POJ3186:Treats for the Cows 区间DP
- POJ3186 Treats for the Cows DP
- POJ3186:Treats for the Cows(区间DP)
- POJ3186:Treats for the Cows(区间DP)
- poj3186(搜索)
- 区间dp入门[POJ2955][HDU2476][POJ3186][POJ1651][HDU4632][HDU4283][HDU4570][POJ3280]
- poj3186解题报告
- poj3186(递推)
- POJ3186+3190+3250
- POJ3186:Treats for the Cows
- jQuery 属性操作 - removeAttr() 方法
- Linux下undefine reference to 'FT_Init_FreeType'的解决办法
- 机器学习---支持向量机(SVM)
- win7启动本地MongoDB的四种方式
- 每天laravel-20160702|CacheTableCommand
- poj3186 dp
- Android Studio debug使用release的签名
- 神经网络基本概念
- 【笔试/面试】 —— 最长递增子序列
- 分类模型到底如何选择
- iOS开发学习之 - 正则表达式在IOS中的应用
- 3.7.3 event_enable_read和event_enable_write:挂载回调函数
- Python函数参数默认值的陷阱和原理深究
- 部署两个tomcat后,系统提示cannot set user id: Resource temporarily unavailable