BZOJ1652 [Usaco2006 Feb]Treats for the Cows】的更多相关文章

跟某NOIP的<矩阵取数游戏>很像. f(i,j)表示从左边取i个,从右边取j个的答案. f[x][y]=max(dp(x-1,y)+a[x]*(x+y),dp(x,y-1)+a[n-y+1]*(x+y)). ans=max{f(i,n-i)}. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define N 2001 int n,a[N],f[N][…
蒟蒻许久没做题了,然后连动规方程都写不出了. 参照iwtwiioi大神,这样表示区间貌似更方便. 令f[i, j]表示i到j还没卖出去,则 f[i, j] = max(f[i + 1, j] + v[i] * T, f[i, j - 1] + v[j] * T) (←这样用推的方式更好想一点..) /************************************************************** Problem: User: rausen Language: Pasc…
dp( L , R ) = max( dp( L + 1 , R ) + V_L * ( n - R + L ) , dp( L , R - 1 ) + V_R * ( n - R + L ) ) 边界 : dp( i , i ) = V[ i ] * n -------------------------------------------------------------------------------------------- #include<cstdio> #include&l…
题目 1652: [Usaco2006 Feb]Treats for the Cows Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 234  Solved: 185[Submit][Status] Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ se…
http://www.lydsy.com/JudgeOnline/problem.php?id=1652 dp.. 我们按间隔的时间分状态k,分别为1-n天 那么每对间隔为k的i和j.而我们假设i或者j在间隔时间内最后取.那么在这个间隔时间内最后取的时间就是n-k+1(这个自己想..也就是说,之前在n-(k-1)+1的时间间隔内取过了,现在我们要多了一个时刻,相当于取这个早了一个时间) 然后就是 k为阶段 i为左端点 j=i+k-1为右端点 t=n-k+1为i-j取最后一个的时间 然后转移 f[…
裸的区间dp,设f[i][j]为区间(i,j)的答案,转移是f[i][j]=max(f[i+1][j]+a[i](n-j+i),f[i][j-1]+a[j]*(n-j+i)); #include<iostream> #include<cstdio> using namespace std; const int N=2005; int n,a[N],f[N][N]; int main() { scanf("%d",&n); for(int i=1;i<…
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…
1651: [Usaco2006 Feb]Stall Reservations 专用牛棚 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 509  Solved: 280[Submit][Status] Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise…
1653: [Usaco2006 Feb]Backward Digit Sums Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 207  Solved: 161[Submit][Status][Discuss] Description FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a cer…
线段树.. -------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream>   #define rep( i , n ) for( int i = 0 ; i < n ; i++ ) #define…