POJ3186(KB12-O DP)】的更多相关文章

题目链接:http://poj.org/problem?id=3186 思路: 区间DP,给treat编号为1..n,状态很明显是上界i和下界j,dp[i][j]表示从下标i到下标j之间数据的最大价值.可以正向转移,从dp[1][0]开始,也可以逆向转移,从dp[i][i]开始.我这里是正向转移,状态转移方程如下: if(i>1&&j<n)                dp[i][j]=max(dp[i-1][j]+(n-1-(j-i))*a[i-1],dp[i][j+1]+…
题意: 每次只能取两端,然后第 i 次取要val[ i ]*i,求一个最大值 一切都是错觉[读者省略此段] 这道题目一开始想的就是记忆化搜索,然后太天真了?好像是,一开始用一维dp[ i ]直接代表一个点的最大...额..现在想想好撒比,怎么可能一维就可以代表一个点的最大啊...因为并不能代表他那一步最大. [解析] 所以开二维数组dp[ s ] [ e ]代表一个区间上的最大,然后深搜一下就好了... 还是菜吧.. 另外还有一种写法是..从里到外的DP,也是非常棒! 记忆化搜索: #inclu…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…
Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5801   Accepted: 3003 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per da…
Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5753   Accepted: 2972 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per da…
Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7949   Accepted: 4217 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per da…
题目链接:http://poj.org/problem?id=3186 题意:给一行n个数,每次可以取出行首或者行末的数,如果第ai是第i次取出的,可以得到ai*i的收益,求最大的总收益: 思路:区间dp 我们可以用dp[i][j]表示当前是取出第i个行首元素,第j次取出行尾元素,那么不然想到动态转移方程式: dp[i][j]=max(dp[i-1][j]+a[i]*(i+j), dp[i][j-1]+a[n-j+1]*(i+j)) 注意一下边界情况就ok啦... 代码: #include <i…
题目链接:http://poj.org/problem?id=3186 Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6548   Accepted: 3446 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amount…
layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathjax: true - kuangbin - 动态规划 传送门 A.HDU1024 Max Sum Plus Plus 题意 给你N个数,然后你分成M个不重叠部分,并且这M个不重叠部分的和最大. 思路 动态规划最大m字段和,dp数组,dp[i][j]表示以a[j]结尾的,i个字段的最大和 两种情况:1.第a[j…
一.数位DP 1.含有或不含某个数“xx”: HDU3555 Bomb HDU2089 不要62 2.满足某些条件,如能整除某个数,或者数位上保持某种特性: HDU3652 B-number CodeForces - 55D Beautiful numbers POJ3252 Round Numbers HDU3709 Balanced Number 二.区间DP: 1.由小区间往左右两边扩散: POJ3186 Treats for the Cows ZOJ3469 Food Delivery…