[USACO10DEC] Treasure Chest】的更多相关文章

题目链接 90 Points:智障的区间 DP--设 dp[i][j] 表示区间 [i, j] 能取的最大价值,但我还是 sd 地开了第三维表示先取还是后取的价值. 交上去以为能 A,结果 #2 开心地 MLE--一看内存,64MB(把评测机吊起来打一顿)-- 100 Points:有些神仙--区间 DP 的滚动数组,dp[i] 表示以 i 为首的区间得到的最大价值. 换一种思路,定义 dp[l][r] 为在区间 [l,r] 先手的人能取到的最大值,区间的长度每加 1,先手就会互换一次,为了让这…
P3004 [USACO10DEC]宝箱Treasure Chest 题目描述 Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk into a store and buy stuff, so instead they decide to have some fun with the coins. The N (1…
P3004 [USACO10DEC]宝箱Treasure Chest 题目描述 Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk into a store and buy stuff, so instead they decide to have some fun with the coins. The N (1…
区间DP,但是卡空间. n2的就是f[i,j]=sum[i,j]-min(f[i+1][j],f[i][j-1])表示这个区间和减去对手取走的最多的. 但是空间是64MB,就很难受 发现一定是由大区间转移到小区间,区间长度差为1 式子变成 :f[i,i+len]=sum[i,i+len]-min(f[i+1,i+len],f[i,i+len-1])然后就枚举len,就可以求出结果. #include <iostream> #include <cstdio> #include <…
2101: [Usaco2010 Dec]Treasure Chest 藏宝箱 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 327  Solved: 147[Submit][Status] Description Bessie and Bonnie have found a treasure chest full of marvelous gold coins! Being cows, though, they can't just walk i…
dp( l , r ) = sum( l , r ) - min( dp( l + 1 , r ) , dp( l , r - 1 ) ) 被卡空间....我们可以发现 l > r 是无意义的 , 所以可以省下一半的空间 -------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<a…
G - Zombie’s Treasure Chest Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description   Some brave warriors come to a lost village. They are very lucky and find a lot of treasures and a big treasure chest,…
 Zombie's Treasure Chest 本题题意:有一个给定容量的大箱子,此箱子只能装蓝宝石和绿宝石,假设蓝绿宝石的数量无限,给定蓝绿宝石的大小和价值,要求是获得最大的价值 题解:本题看似是dp中的背包问题,但是由于数据量太大,用dp肯定会超时,所以只能寻找另外一种思路,可以用贪心加暴力,先求出两种宝石大小的最小公倍数com,然后将N/com-com,与N%comkanchengs看成是两个部分(想想应该明白).将前一个部分,放入单位价值量最高的那个,对于后面那个部分直接将S1的数量从…
Zombie’s Treasure Chest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4442    Accepted Submission(s): 889 Problem Description   Some brave warriors come to a lost village. They are very lucky…
http://www.lydsy.com/JudgeOnline/problem.php?id=2101 这个dp真是神思想orz 设状态f[i, j]表示i-j先手所拿最大值,注意,是先手 所以转移自然而然的变成 f[i, j]=sum[i, j]-min(f[i+1, j], f[i, j-1]) 这个转移很好理解吧 但是本题开二维会mle.. 我们考虑以阶段来dp 我们发现,可以按长度为阶段 f[i, i+len]=sum[i, i+len]-min{f[i+1, i+len], f[i,…