poj3186 Treats for the Cows(区间)】的更多相关文章

题目链接:http://poj.org/problem?id=3186 题意:第一个数是N,接下来N个数,每次只能从队列的首或者尾取出元素. ans=每次取出的值*出列的序号.求ans的最大值. 样例 : input:5  1 2 1 5 2 output:43 思路:区间dp,用两个指针i和j代表区间,dp[i][j]表示这个区间的最大值. ///最开始想想着每次拿值最小的就好了,因为之前没接触过区间dp,就这样naive的交了,意料之中的WA了. ///找到一个范例 eg:1000001  …
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: 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…
题目链接  Treats for the Cows 直接区间DP就好了,用记忆化搜索是很方便的. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define rep(i,a,b) for(int i(a); i <= (b); ++i) #define LL long long + ; LL f[Q]…
题目链接: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…
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 reasons…
http://poj.org/problem?id=3186 Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4041   Accepted: 2063 Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of…
题目来源:http://poj.org/problem?id=3186 (http://www.fjutacm.com/Problem.jsp?pid=1389) /** 题目意思: 约翰经常给产奶量高的奶牛发特殊津贴,于是很快奶牛们拥有了大笔不知该怎么花的钱. 为此,约翰购置了N(1≤N≤2000)份美味的零食来卖给奶牛们.每天约翰售出一份零食. 当然约翰希望这些零食全部售出后能得到最大的收益.这些零食有以下这些有趣的特性: 零食按照1..N编号,它们被排成一列放在一个很长的盒子里.盒子的两端…
P2858 [USACO06FEB]奶牛零食Treats for the Cows区间dp,级像矩阵取数, f[i][i+l]=max(f[i+1][i+l]+a[i]*(m-l),f[i][i+l-1]+a[i+l]*(m-l)); #include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cmath> #include<ctime&g…
P2858 [USACO06FEB]奶牛零食Treats for the Cows 区间dp 设$f[l][r]$为取区间$[l,r]$的最优解,蓝后倒着推 $f[l][r]=max(f[l+1][r]+a[l]*p,f[l][r-1]+a[r]*p)$ #include<iostream> #include<cstdio> #include<cstring> using namespace std; int max(int a,int b){return a>b…