01++ Bookshelf 2】的更多相关文章

http://poj.org/problem?id=3628 就是比原题多了一个要求,输出>=m的最小值 kisang~独立做出来的都开心<( ̄︶ ̄)> #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; ],d[],f[]; int main() { int…
Bookshelf 2 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8745   Accepted: 3974 Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available…
Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available space is at the top. FJ has N cows (1 ≤ N ≤ 20) each with some height of Hi (1 ≤ Hi ≤ 1,000,00…
题目链接:Bookshelf 2(点击进入) 题目解读: 给n头牛,给出每个牛的高度h[i],给出一个书架的高度b(所有牛的高度相加>书架高度b),现在把一些牛叠起来(每头牛只能用一次,但不同的牛可能身高相同),在这些叠起来的牛的总高度>书架b的基础上,找出最小的差距(由于输入的数据会保证所有牛的高度相加>书架高度b,所以差距不为负) 还是看不懂题目? 举个栗子: 现在有五头牛高度分别为3 1 3 5 6,书架高度b=16,我们可以把五头牛都叠起来,总高度为18,差距为18-16=2,但…
Bookshelf 2 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7496   Accepted: 3451 Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available…
Bookshelf 2 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9488   Accepted: 4311 Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available…
题意:给出n头牛的身高,以及一个书架的高度,问怎样选取牛,使得它们的高的和超过书架的高度最小. 将背包容量转化为所有牛的身高之和,就可以用01背包来做=== #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 2000005 using namespace std; ]; int main() { ,tmp=; scanf("%…
传送门:http://poj.org/problem?id=3628 题目看了老半天,牛来叠罗汉- -|||和书架什么关系啊.. 大意是:一群牛来叠罗汉,求超过书架的最小高度. 0-1背包的问题,对于第i只牛可以放或者不放.然后最后求出大于书架高度的,减去书架高度即可. 也可以倒着来看.背包的容量为牛总的高度-书架的高度,求不超过这个容量的最大值,最后容量-这个值就是答案了.(推荐) 还可以DFS.. #include<cstdio> #include<cstring> #incl…
题目http://poj.org/problem?id=3628 分析:给定一堆牛的高度,把牛叠加起来的高度超过牛棚的高度. 且是牛叠加的高度与牛棚高度之差最小. 把牛叠加的高度看作是背包的容量,利用01背包计算所能达到的最大值. 然后在最大值里面选择一个与牛棚高度差值最小的. 在开辟dp[]数组的时候没有必要开辟20*1000000不然会超过内存,适当小一点即可. #include<stdio.h>#include<string.h>const int INF=0XFFFFFF;…
B - Bookshelf 2 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only…