HDOJ5543 Pick The Sticks】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:往长为L的线段上覆盖线段,要求:要么这些线段都在L的线段上,要么有不超过自身长度一半的部分在线段外面,最多有两条这样的线段(在两头). dp(i,j,k)表示前i个线段覆盖在长度为j的线段上,期中有k个线段不完全在这个线段上的最大价值.考虑线段长度的奇偶问题,所以事先把L和其他线段长度乘2,以便操作.所以枚举所有线段,一般情况,就是01背包的问题,dp(i,j,k)=max(dp(i,j…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题目大意:有n个金条,每个金条有长度和价值,给一个长度为L的容器,当金条在容器两端的时候,只要重心在容器内也可以放下,问最多能获得的价值. 思路:01背包,但是重心怎么处理,最好的肯定是边界情况也就是刚好金条刚好能伸出一半,或者直接只取一根金条然后放在容器里面. 多开一位 dp[i][j][k]代表当前选第i个背包容量为j有k个超出边缘的金条时所能获得的最大价值 状态转移方程 dp[i][j]…
Pick The Sticks Time Limit: 15000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 593    Accepted Submission(s): 193 Problem Description The story happened long long ago. One day, Cao Cao made a special order c…
D - Pick The Sticks Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became very panic. However, Cao…
Pick The Sticks Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became v…
D - Pick The Sticks Description The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became very panic. However, Cao Cao himself felt very proud of his interesting…
Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit  Status The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became ve…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:给你一根长为m的长木板和一些小木棒,每一根小木棒有它的长度和价值,这些小木棒要放在长木板上并且每一根小木棒的重心要在长木板上(即可以露出一半的长),问最大价值是多少. dp[i][j][k]  表示前i个小棒放到长度为j的木板上,其中有k个小棒放在边沿部分, 边沿部分的小棒需要尽量放在木板外面(贪心思维),所以放在边沿的木棒落在木板上的长度为l/2.然后就是简单的01背包问题了. tip…
题目传送门 题意:长度为L的金条,将n根金棍尽可能放上去,要求重心在L上,使得价值最大,最多有两条可以长度折半的放上去. 分析:首先长度可能为奇数,先*2.然后除了两条特殊的金棍就是01背包,所以dp[now][j][k]表示当前状态,长度为j,使用了k条特殊金棍获得的最大价值,需要对内存和时间优化. /************************************************ * Author :Running_Time * Created Time :2015/10/2…
题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可以伸一半的长度在容器外,求最大价值量 01背包是取和不取.那这里我们可以把容器长度 l x 2,筷子长度 x 2,就变成了最多两个筷子取一次(伸一半在外面),其余的要么取两次,要么不取. 普通01背包,一维dp[i]表示消耗体积i所得到的最大的价值. 那么这里dp[i][k]表示消耗体积i并有k(k…