BZOJ 1649: [Usaco2006 Dec]Cow Roller Coaster( dp )
有点类似背包 , 就是那样子搞...
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
1649: [Usaco2006 Dec]Cow Roller Coaster
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 440 Solved: 233
[Submit][Status][Discuss]
Description
The cows are building a roller coaster! They want your help to design as fun a roller coaster as possible, while keeping to the budget. The roller coaster will be built on a long linear stretch of land of length L (1 <= L <= 1,000). The roller coaster comprises a collection of some of the N (1 <= N <= 10,000) different interchangable components. Each component i has a fixed length Wi (1 <= Wi <= L). Due to varying terrain, each component i can be only built starting at location Xi (0 <= Xi <= L-Wi). The cows want to string together various roller coaster components starting at 0 and ending at L so that the end of each component (except the last) is the start of the next component. Each component i has a "fun rating" Fi (1 <= Fi <= 1,000,000) and a cost Ci (1 <= Ci <= 1000). The total fun of the roller coster is the sum of the fun from each component used; the total cost is likewise the sum of the costs of each component used. The cows' total budget is B (1 <= B <= 1000). Help the cows determine the most fun roller coaster that they can build with their budget.
Input
* Line 1: Three space-separated integers: L, N and B.
* Lines 2..N+1: Line i+1 contains four space-separated integers, respectively: Xi, Wi, Fi, and Ci.
Output
* Line 1: A single integer that is the maximum fun value that a roller-coaster can have while staying within the budget and meeting all the other constraints. If it is not possible to build a roller-coaster within budget, output -1.
Sample Input
0 2 20 6
2 3 5 6
0 1 2 1
1 1 1 3
1 2 5 4
3 2 10 2
Sample Output
选用第3条,第5条和第6条钢轨
HINT
Source
BZOJ 1649: [Usaco2006 Dec]Cow Roller Coaster( dp )的更多相关文章
- BZOJ——1649: [Usaco2006 Dec]Cow Roller Coaster
http://www.lydsy.com/JudgeOnline/problem.php?id=1649 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 7 ...
- bzoj 1649: [Usaco2006 Dec]Cow Roller Coaster【dp】
DAG上的dp 因为本身升序就是拓扑序,所以建出图来直接从1到ndp即可,设f[i][j]为到i花费了j #include<iostream> #include<cstdio> ...
- 【BZOJ】1649: [Usaco2006 Dec]Cow Roller Coaster(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1649 又是题解... 设f[i][j]表示费用i长度j得到的最大乐趣 f[i][end[a]]=ma ...
- bzoj1649 [Usaco2006 Dec]Cow Roller Coaster
Description The cows are building a roller coaster! They want your help to design as fun a roller co ...
- 【动态规划】bzoj1649 [Usaco2006 Dec]Cow Roller Coaster
很像背包. 这种在一个数轴上进行操作的题常常需要对区间排序. f[i][j]表示距离到i时,花费为j时的权值之和. f[x[i]+l[i]][j+c[i]]=max{f[x[i]][j]+w[i]}( ...
- Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 554 Solved: 346[ ...
- BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐( dfs )
直接从每个奶牛所在的farm dfs , 然后算一下.. ----------------------------------------------------------------------- ...
- BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is graz ...
- bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐【dfs】
从每个奶牛所在草场dfs,把沿途dfs到的草场的con都+1,最后符合条件的草场就是con==k的,扫一遍统计一下即可 #include<iostream> #include<cst ...
随机推荐
- uvalive5810 uva12368 Candles
题意:每组数据给出n个数,每个数在1-100,问组成这些数的蜡烛的权值的最小值.权值=把选的蜡烛从大到小排列组成的数 组成方式:比如有1 3两个蜡烛 可以组成13(1和3)或4(1+3) 只有一个加号 ...
- 许士彦:创业不走寻常路 APP最好时间已过
从用户体验服务设计公司eico design到拥有两千多万用户的独立微博客户端Weico,再到备受欢迎的影像APP(微可拍,Weico Gif),Weico团队走过了一条不寻常的创业之路. 作为一家新 ...
- [学习笔记]viewport定义,弹性布局,响应式布局
一,移动端宽度设置viewport视图窗口,<meta name="viewport" content="width=device-width,initial-sc ...
- <%=id%>是什么意思
<%=% > 这里可以绑定后台的一个PUBLIC变量 <% % > 如果没有等号 可以在里面写C#语句
- tomcat最大线程数的设置(转)
1.Tomcat的server.xml中连接器设置如下 <Connector port="8080" maxThreads="150" minSpareT ...
- BZOJ 1037: [ZJOI2008]生日聚会Party( dp )
dp(i, j, a, b)表示选了i个男生, j个女生, 后缀中男生比女生多a(最多), 女生比男生多b(最多). dp(i+1, j, a+1, max(0, b-1)) += dp(i, j, ...
- SGU 134.Centroid( 树形dp )
一道入门树dp, 求一棵树的重心...我是有多无聊去写这种题...傻X题写了也没啥卵用以后还是少写好.. ----------------------------------------------- ...
- 关于BFC
参考 http://www.html-js.com/article/1866(很棒! 还有栗子) http://www.cnblogs.com/lhb25/p/inside-block-format ...
- Delphi内存操作API函数(备查,并一一学习)
Delphi内存操作API函数System.IsMemoryManagerSet;System.Move;System.New;System.ReallocMem;System.ReallocMemo ...
- PHP下通过file_get_contents\curl的方法实现获取远程网页内容(别忘了还有PhpRPC)
[php]PHP中file_get_contents()与file_put_contents()函数细节详解 php函数file_get_contents(一) 案例: 早在2010年时候遇到过这样的 ...