BZOJ1652 [Usaco2006 Feb]Treats for the Cows

蒟蒻许久没做题了,然后连动规方程都写不出了。

参照iwtwiioi大神,这样表示区间貌似更方便。

令f[i, j]表示i到j还没卖出去,则

f[i, j] = max(f[i + 1, j] + v[i] * T, f[i, j - 1] + v[j] * T) (←这样用推的方式更好想一点。。)

 1 /**************************************************************
 2     Problem: 1652
 3     User: rausen
 4     Language: Pascal
 5     Result: Accepted
 6     Time:136 ms
 7     Memory:24852 kb
 8 ****************************************************************/
 9
10 uses math;
11
12 var
13   n, k, i, j, t : longint;
14   f : array[0..2500, 0..2500] of longint;
15   v : array[0..2500] of longint;
16
17 begin
18   readln(n);
19   for i := 1 to n do
20     read(v[i]);
21   for k := 1 to n do begin
22     t := n - k + 1;
23     for i := 1 to t do begin
24       j := i + k - 1;
25       f[i, j] := max(f[i + 1, j] + t * v[i], f[i, j - 1] + t * v[j]);
26     end;
27   end;
28   writeln(f[1, n]);
29 end.

时间: 2024-10-28 21:09:48

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

BZOJ1652 [Usaco2006 Feb]Treats for the Cows 区间动归

约翰经常给产奶量高的奶牛发特殊津贴,于是很快奶牛们拥有了大笔不知该怎么花的钱.为此,约翰购置了N(1≤N≤2000)份美味的零食来卖给奶牛们.每天约翰售出一份零食.当然约翰希望这些零食全部售出后能得到最大的收益.这些零食有以下这些有趣的特性: ?零食按照1..N编号,它们被排成一列放在一个很长的盒子里.盒子的两端都有开口,约翰每 天可以从盒子的任一端取出最外面的一个. ?与美酒与好吃的奶酪相似,这些零食储存得越久就越好吃.当然,这样约翰就可以把它们卖出更高的价钱. ?每份零食的初始价值不一定相同

【记忆化搜索】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][

BZOJ 1652: [Usaco2006 Feb]Treats for the Cows( dp )

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

BZOJ 1652: [Usaco2006 Feb]Treats for the Cows

题目 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

bzoj1652:treats for the cows

1652: [Usaco2006 Feb]Treats for the Cows Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 271  Solved: 209[Submit][Status][Discuss] Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk.

BZOJ1653: [Usaco2006 Feb]Backward Digit Sums

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

BZOJ 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚( 线段树 )

线段树.. -------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; i++ ) #define c

BZOJ 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚

题目 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 553  Solved: 307[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 preci

poj-3816 Treats for the Cows 【区间DP】

Treats for the Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4259   Accepted: 2150 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