BZOJ2021: [Usaco2010 Jan]Cheese Towers】的更多相关文章

2021: [Usaco2010 Jan]Cheese Towers Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 184  Solved: 107[Submit][Status] Description Farmer John wants to save some blocks of his cows' delicious Wisconsin cheese varieties in his cellar for the coming winter.…
http://www.lydsy.com/JudgeOnline/problem.php?id=2021 噗,自己太弱想不到. 原来是2次背包. 由于只要有一个大于k的高度的,而且这个必须放在最顶,那么我们就可以枚举每一个比k大的放在最顶,其它的都放在下边即可. 还有,注意这是完全背包! #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <i…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2021 题意: John要建一个奶酪塔,高度最大为m. 他有n种奶酪.第i种高度为h[i](一定是5的倍数),价值为w[i]. 一块高度>=t的奶酪被称为大奶酪,一个奶酪如果在它上方有大奶酪(多块只算一次),它的高度就会变成原来的4/5. John想让他的奶酪他价值和最大,求这个最大值. 题解: 方法一: dp + 贪心. 贪心:如果奶酪塔中有大奶酪,则大奶酪一定放在最上面. (1)有大奶…
题目大意:全然背包.假设最顶端的物品重量≥k,那么以下的全部物品的重量变为原来的45 考虑一些物品装进背包,显然我要把全部重量大于≥k的物品中重量最小的那个放在最顶端.才干保证总重量最小 那么我们给物品排个序,第一键值为重量是否≥k(≥k的放在前面),第二键值为重量(从小到大) 然后依次增加背包.令fi表示没有重量≥k的物品放在最顶端时重量为i的最大价值.gi表示有重量≥k的物品放在最顶端是重量为i的最大价值.DP就可以 时间复杂度O(nT) #include <cstdio> #includ…
2020: [Usaco2010 Jan]Buying Feed, II Time Limit: 3 Sec  Memory Limit: 64 MBSubmit: 220  Solved: 162[Submit][Status] Description (buying.pas/buying.in/buying.out 128M 1S) Farmer John needs to travel to town to pick up K (1 <= K <= 100) pounds of feed…
1783: [Usaco2010 Jan]Taking Turns Description Farmer John has invented a new way of feeding his cows. He lays out N (1 <= N <= 700,000) hay bales conveniently numbered 1..N in a long line in the barn. Hay bale i has weight W_i (1 <= W_i <= 2,0…
P2979 [USACO10JAN]奶酪塔Cheese Towers 背包dp 不过多了一个大奶酪可以压扁其他奶酪的 一开始写了个暴力82分.贪心的选择 然后发现,有如下两种规律 要么最优都是小奶酪,要么就是有一个大奶酪是在顶上的. 所以我们先用小奶酪跑一遍背包,记录最优值. 然后加上大奶酪,不考虑压缩的再跑一遍.因为如果大奶酪在上面的话,我们就不用考虑在dp中压缩,直接跑完dp后.看做一大块一起压缩 #include<iostream> #include<algorithm> #…
P2979 [USACO10JAN]奶酪塔Cheese Towers 题目描述 Farmer John wants to save some blocks of his cows' delicious Wisconsin cheese varieties in his cellar for the coming winter. He has room for one tower of cheese in his cellar, and that tower's height can be at…
题目描述 Farmer John wants to save some blocks of his cows' delicious Wisconsin cheese varieties in his cellar for the coming winter. He has room for one tower of cheese in his cellar, and that tower's height can be at most T (1 <= T <= 1,000). The cows…
题意: 一排数,两个人轮流取数,保证取的位置递增,每个人要使自己取的数的和尽量大,求两个人都在最优策略下取的和各是多少. 注:双方都知道对方也是按照最优策略取的... 傻逼推了半天dp......然后看kpm的代码里一个语句解决 KPM大概思路:倒着取,设当前两人最大和分别为A和B(A为先取的人)..如果B+W[i]>A就把A和B交换(先取的人可以按照更优的取法,后手无人权..)..让A取W[i] 接下来是蒟蒻的傻逼写法: f[0][i],f[1][i]分别表示第1个人和第2个人,在i~n中取了…