POJ 3186 Treats for the Cows 一个简单DP】的更多相关文章

DP[i][j]表示现在开头是i物品,结尾是j物品的最大值,最后扫一遍dp[1][1]-dp[n][n]就可得到答案了 稍微想一下,就可以, #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<cstring> #include<cstring> #include<vect…
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…
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…
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…
简单DP dp[i][j]表示的是i到j这段区间获得的a[i]*(j-i)+... ...+a[j-1]*(n-1)+a[j]*n最大值 那么[i,j]这个区间的最大值肯定是由[i+1,j]与[i,j-1]区间加上端点的较大值推过来的. #include<cstdio> #include<cstring> #include<cmath> #include<stack> #include<vector> #include<string>…
第一眼感觉是贪心,,果断WA.然后又设计了一个两个方向的dp方法,虽然觉得有点不对,但是过了样例,交了一发,还是WA,不知道为什么不对= =,感觉是dp的挺有道理的,,代码如下(WA的): #include <stdio.h> #include <algorithm> #include <string.h> using namespace std; + ; int a[N]; int dp[N][N]; int n; int getDay(int i,int j) {…
Treats for the Cows 先搬中文 Descriptions: 给你n个数字v(1),v(2),...,v(n-1),v(n),每次你可以取出最左端的数字或者取出最右端的数字,一共取n次取完.假设你第i次取的数字是x,你可以获得i*x的价值.你需要规划取数顺序,使获得的总价值之和最大. Input 第一行一个数字n(1<=n<=2000). 下面n行每行一个数字v(i).(1<=v(i)<=1000) Output 输出一个数字,表示最大总价值和. Sample In…
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…
题目描述 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 many re…
题目传送门 做完A Game以后找道区间dp练练手...结果这题没写出来(哭). 和A Game一样的性质,从两边取,但是竟然还有天数,鉴于之前做dp经常在状态中少保存一些东西,所以这次精心设计了状态(不对的). 开始的naive想法:设f[i][j][0/1]为把第1~i / i~n的零食兜售完所得的最多钱,然后我们就会发现这个状态十分难转移. 水题还看了题解. 十分朴素的区间dp,和我在能量项链总结的如出一辙. 本题突破口:可以直接通过区间来得出当前是第几天!! Code #include<…