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
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
1652: [Usaco2006 Feb]Treats for the Cows
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 250 Solved: 199
[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. 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: * The treats are numbered 1..N and stored sequentially in single file in a long box that is open at both ends. On any day, FJ can retrieve one treat from either end of his stash of treats. * Like fine wines and delicious cheeses, the treats improve with age and command greater prices. * The treats are not uniform: some are better and have higher intrinsic value. Treat i has value v(i) (1 <= v(i) <= 1000). * Cows pay more for treats that have aged longer: a cow will pay v(i)*a for a treat of age a. Given the values v(i) of each of the treats lined up in order of the index i in their box, what is the greatest value FJ can receive for them if he orders their sale optimally? The first treat is sold on day 1 and has age a=1. Each subsequent day increases the age by 1.
约翰经常给产奶量高的奶牛发特殊津贴,于是很快奶牛们拥有了大笔不知该怎么花的钱.为此,约翰购置了N(1≤N≤2000)份美味的零食来卖给奶牛们.每天约翰售出一份零食.当然约翰希望这些零食全部售出后能得到最大的收益.这些零食有以下这些有趣的特性:
Input
* Line 1: A single integer,
N * Lines 2..N+1: Line i+1 contains the value of treat v(i)
Output
* Line 1: The maximum revenue FJ can achieve by selling the treats
Sample Input
1
3
1
5
2
Five treats. On the first day FJ can sell either treat #1 (value 1) or
treat #5 (value 2).
Sample Output
OUTPUT DETAILS:
FJ sells the treats (values 1, 3, 1, 5, 2) in the following order
of indices: 1, 5, 2, 3, 4, making 1x1 + 2x2 + 3x3 + 4x1 + 5x5 = 43.
HINT
Source
BZOJ 1652: [Usaco2006 Feb]Treats for the Cows( dp )的更多相关文章
- BZOJ 1652: [Usaco2006 Feb]Treats for the Cows
题目 1652: [Usaco2006 Feb]Treats for the Cows Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 234 Solve ...
- bzoj 1652: [Usaco2006 Feb]Treats for the Cows【区间dp】
裸的区间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< ...
- 【BZOJ】1652: [Usaco2006 Feb]Treats for the Cows(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1652 dp.. 我们按间隔的时间分状态k,分别为1-n天 那么每对间隔为k的i和j.而我们假设i或者 ...
- [BZOJ 1652][USACO 06FEB]Treats for the Cows 题解(区间DP)
[BZOJ 1652][USACO 06FEB]Treats for the Cows Description FJ has purchased N (1 <= N <= 2000) yu ...
- 【记忆化搜索】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+ ...
- BZOJ1652 [Usaco2006 Feb]Treats for the Cows
蒟蒻许久没做题了,然后连动规方程都写不出了. 参照iwtwiioi大神,这样表示区间貌似更方便. 令f[i, j]表示i到j还没卖出去,则 f[i, j] = max(f[i + 1, j] + v[ ...
- BZOJ 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚( 线段树 )
线段树.. -------------------------------------------------------------------------------------- #includ ...
- BZOJ 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚
题目 1651: [Usaco2006 Feb]Stall Reservations 专用牛棚 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 553 ...
- poj 3186 Treats for the Cows(dp)
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for gi ...
随机推荐
- MySQLD 配置
http://blog.163.com/sir_876/blog/static/11705223201372710303382/ http://www.kankanews.com/ICkengine/ ...
- USB創意讀卡機設計特別獎
- 【高级】C++中虚函数机制的实现原理
多态是C++中的一个重要特性,而虚函数却是实现多态的基石.所谓多态,就是基类的引用或者指针可以根据其实际指向的子类类型而表现出不同的功能.这篇文章讨论这种功能的实现原理,注意这里并不以某个具体的编译器 ...
- sqlplus conn远程连接
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.in ...
- display:table标签来自动改变列宽 改变的同时table的整体宽度跟随变化
发现公司里的所有分页功能都是通过display:talbe来实现的,但是用户最近说要让表格列宽可以拖动:所有我就寻找了好多的办法:网上找了很多的资料,但是都不是我要的效果因为他们都是列宽不改变要不就是 ...
- TerminateThread函数学习
终结一个线程. BOOL WINAPI TerminateThread( _Inout_ HANDLE hThread, _In_ DWORD dwExitCode ); Parameter ...
- [学习笔记]HTML5之canvas
虐了一下午的canvas 先撸了一个七巧板 <!doctype html> <html> <head> <meta charset="utf-8&q ...
- Javascript Duff装置 循环展开(Javascript Loop unrolling Duff device)
Javascript 中会用到for 循环,当要循环的数据记录很多的时候,可能会对性能产生很大影响.这时我们可以考虑展开for循环,这时就要用到Duff装置(Duff Device). 先来看一个小例 ...
- If the server requires more time, try increasing the timeout in the server editor
双击服务器,在overview下的Timeouts中的Start选项,改成10000或者较大就可以了.防止服务器自启动频繁.
- css 一些事
1.两个div左边的固定宽度右边的自动填充的css <div id="main" style="width:98%;"> <div id=&q ...