BZOJ——1606: [Usaco2008 Dec]Hay For Sale 购买干草
http://www.lydsy.com/JudgeOnline/problem.php?id=1606
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 1420 Solved: 1052
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
2
6
5
The wagon holds 7 volumetric units; three bales are offered for sale with
volumes of 2, 6, and 5 units, respectively.
Sample Output
HINT
Buying the two smaller bales fills the wagon.
Source
#include <cstdio> #define max(a,b) (a>b?a:b) inline void read(int &x)
{
x=; register char ch=getchar();
for(; ch>''||ch<''; ) ch=getchar();
for(; ch>=''&&ch<=''; ch=getchar()) x=x*+ch-'';
}
int C,H,v[],f[]; int Presist()
{
read(C),read(H);
for(int i=; i<=H; ++i) read(v[i]);
for(int i=; i<=H; ++i)
for(int j=C; j>=v[i]; j--)
f[j]=max(f[j],f[j-v[i]]+v[i]);
printf("%d\n",f[C]);
return ;
} int Aptal=Presist();
int main(int argc,char**argv){;}
BZOJ——1606: [Usaco2008 Dec]Hay For Sale 购买干草的更多相关文章
- BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草( dp )
-------------------------------------------------------------------- #include<cstdio> #include ...
- 01背包 || BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草 || Luogu P2925 [USACO08DEC]干草出售Hay For Sale
题面:P2925 [USACO08DEC]干草出售Hay For Sale 题解:无 代码: #include<cstdio> #include<cstring> #inclu ...
- bzoj 1606: [Usaco2008 Dec]Hay For Sale 购买干草
Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包 ...
- BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草(动态规划)
裸的背包= =,没什么好说的= = CODE: #include<cstdio>#include<iostream>#include<algorithm>#incl ...
- bzoj 1606: [Usaco2008 Dec]Hay For Sale 购买干草【01背包】
在洛谷上被卡常了一个点! 就是裸的01背包咯 为啥我在刷水题啊 #include<iostream> #include<cstdio> #include<algorith ...
- 1606: [Usaco2008 Dec]Hay For Sale 购买干草
Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包 ...
- BZOJ1606: [Usaco2008 Dec]Hay For Sale 购买干草
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 612 Solved: 46 ...
- bzo1606: [Usaco2008 Dec]Hay For Sale 购买干草
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1338 Solved: 9 ...
- bzoj1606[Usaco2008 Dec]Hay For Sale 购买干草(01背包)
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1240 Solved: 9 ...
随机推荐
- 【转】CPU个数,核心数,线程数
我们在买电脑的时候,经常会看cpu的参数,对cpu的描述有这几种:“双核”.“双核四线程”.“四核”.“四核四线程”.“四核8线程”……. 我们接触的电脑基本上都只有一个cup.cpu的个数很容易得到 ...
- [置顶] IIS应用程序池多工作进程设置及Session共享
[置顶] IIS应用程序池多工作进程设置及Session共享 在调优iis的时候,朋友分享给我一个特别棒的设置方法步骤,感谢好朋友的分享. IIS应用程序池多工作进程设置及Session共享 1 ...
- NoSQL 之 Morphia 操作 MongoDB
上两篇文章:http://www.cnblogs.com/hoojo/archive/2011/06/01/2066426.html http://www.cnblogs.com/hoojo/arch ...
- C语言运算符_03
·运算符的优先级:C语言中,运算符的优先级共分为15级.1级最高,15级最低.在表达式中,优先级较高的先于优先级较低的进行运算.而在同一个运算量两侧的运算符优先级相同时,则按运算符的结合性所规定的结合 ...
- IntelliJ IDEA 中自定义模板代码的缩写
方法一:新建 Live Template step1. 点击 File – Setting step2.选择 Live Template,点击右侧的+号,选择 Template Group step3 ...
- uboot的readme
## (C) Copyright 2000 - 2008# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## See file CREDI ...
- 杭电 1159 Common Subsequence
Problem Description A subsequence of a given sequence is the given sequence with some elements (poss ...
- WIN10配置MAVEN
添加新的系统环境变量M2_HOME, 并设置其值为你安装的目录MAVEN_HOME=D:\Softwares\apache-maven-3.2.2. 更新系统PATH 变量, 添加;%M2_HOME% ...
- luogu3629 [APIO2010]巡逻
创造一个环出来,可以让环上的边都只访问一次. 对于 \(k=1\),答案就是树的直径两边连起来. 倘若 \(k=2\),那就先按照 \(k=1\) 的求一遍,然后我们发现,如果第二条加的边构成的环和第 ...
- Nginx出现403 forbidden(Permission denied)报错的四种方法
查看nginx的error.log日志.打开日志出现Permission denied: 1.启动用户和nginx的工作用户不一致所致 查看nginx的启动用户,发现是www,而为是用root启动的 ...