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

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 <…
题目:https://www.luogu.org/problemnew/show/P3004 一眼看上去就是记忆化搜索的dp.像 一双木棋 一样. 结果忘了记忆化.T了5个点. 然后加上记忆化.MLE. 参考一些,改成循环的dp.还是MLE.哈哈,根本没改数组大小嘛! 又参考一些. 分析转移,发现它可以设计成滚动数组. 总之就是这样一道明明是简单题的题.自己还是需要多练习…… #include<iostream> #include<cstdio> #include<cstri…
第一眼:区间DP,可以瞎搞 f[i][j]=max(sum(i,j)-f[i+1][j],sum(i,j)-f[i][j-1]) 提出来就是f[i][j]=sum(i,j)-min(f[i+1][j],f[i][j-1]) 可是空间是64M,就很难受,第二个数据点是极限数据 尝试了用部分记忆化的方式找空间时间平衡,但是这样显然是不对的,看起来“省下的空间”实际上成为了更多的栈空间.. 考虑写一维的DP,既然不可能消一维,就把另一维藏起来. f[i]表示原来的f[i][i+len],外层依旧枚举l…
题目:https://www.luogu.org/problemnew/show/P3004 似乎有点博弈的意思,但其实是DP: f[i][j] 表示 i~j 的最优结果,就可以进行转移: 注意两个循环的顺序,要先算出 i+1 ,但要用之前的 j-1 ,所以一个倒序一个正序. 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; ][],s[]; int main…
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,…
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…
 Zombie's Treasure Chest 本题题意:有一个给定容量的大箱子,此箱子只能装蓝宝石和绿宝石,假设蓝绿宝石的数量无限,给定蓝绿宝石的大小和价值,要求是获得最大的价值 题解:本题看似是dp中的背包问题,但是由于数据量太大,用dp肯定会超时,所以只能寻找另外一种思路,可以用贪心加暴力,先求出两种宝石大小的最小公倍数com,然后将N/com-com,与N%comkanchengs看成是两个部分(想想应该明白).将前一个部分,放入单位价值量最高的那个,对于后面那个部分直接将S1的数量从…