BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草
1606: [Usaco2008 Dec]Hay For Sale 购买干草
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
——我是华丽的分割线——
一个安静的背包DP.....
代码:
#include<cstdio>
using namespace std;
int c,h;
int v[5010];
bool f[50010];
int main(){scanf("%d%d",&c,&h);for (int i=1;i<=h;i++) scanf("%d",&v[i]);f[0]=true;for (int i=1;i<=h;i++){for (int j=c;j>=v[i];j--){if (f[j-v[i]]) f[j]=true;}}for (int i=c;i>=0;i--){if (f[i]){printf("%d\n",i);return 0;}}return 0;
}
转载于:https://www.cnblogs.com/WNJXYK/p/4063957.html
BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草相关推荐
- bzoj 1606 [Usaco2008 Dec]Hay For Sale 购买干草(01背包)
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1300 Solved: ...
- [BZOJ] 1606: [Usaco2008 Dec]Hay For Sale 购买干草
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1335 Solved: ...
- 01背包 || BZOJ 1606: [Usaco2008 Dec]Hay For Sale 购买干草 || Luogu P2925 [USACO08DEC]干草出售Hay For Sale...
题面:P2925 [USACO08DEC]干草出售Hay For Sale 题解:无 代码: 1 #include<cstdio> 2 #include<cstring> 3 ...
- bzoj 1607: [Usaco2008 Dec]Patting Heads 轻拍牛头
翻过来考虑影响,考虑多少数是他的倍数. 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 ...
- BZOJ 1607 [Usaco2008 Dec]Patting Heads 轻拍牛头:统计 + 筛法【调和级数】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1607 题意: 给你n个数,问你除a[i]之外,有多少个数是a[i]的约数. 题解: ans ...
- BZOJ_1606_ [Usaco2008_Dec]_Hay_For_Sale _购买干草_(背包)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1606 价值和重量相等的01背包问题. 分析 ... 1 #include <bits/s ...
- bzoj 1618: [Usaco2008 Nov]Buying Hay 购买干草(完全背包)
1618: [Usaco2008 Nov]Buying Hay 购买干草 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1196 Solved: 62 ...
- bzoj 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机
1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机 Time Limit: 5 Sec Memory Limit: 64 MB Submit: ...
- BZOJ 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机 bfs
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1615 1615: [Usaco2008 Mar]The Loathesome Hay Bale ...
最新文章
- bugku 杂项 就五层你能解开吗_你能解开这个和数字有关的逻辑解谜游戏吗? | 每日一考...
- freemarker ftl模板_Spring Boot2 系列教程(十)Spring Boot 整合 Freemarker
- Elasticsearch(二)概念及安装、部署
- LiveVideoStackCon深圳-精选最新多媒体技术方案
- Mac备份工具:Carbon Copy Cloner Mac支持m1
- 利用python开发微信JS-JDK(基于python3.6)
- python find next_bitset中_Find_first()与_Find_next()函数
- tf 单个文字识别 data 数据输入
- c语言printf分析,C语言 printf详解
- 【Spinning up】零、DRLib:一个简洁的强化学习库,集成了HER和PER
- 神奇的幻方(洛谷)c语言
- Vultr centost7一键安装BBR工具教程
- git 拉取远端分支
- 程序员微信名昵称_数据分析告诉你,微信里好友们的昵称,也是一门很深的学问...
- FFmpeg —— librtmp的安装(linux)
- ECL电平特点及其应用
- SQL Server 2005 SP3正式版下载
- 5.1Kettle数据的清洗与检验——不完全去重
- buddypress主题_WordPress Gone Social-BuddyPress
- php mysql 别名_php和mysql的一些奇怪之处
热门文章
- python中continue格式_python自学(3)--for 、 while、 break、continue、字符格式化输出...
- python web开发 CSS基础
- LeetCode 1153. 字符串转化(哈希)
- LeetCode 1053. 交换一次的先前排列
- python连接sql数据库_python连接SQL数据库
- 桌面软件打开都会变成计算机,我不小心把电脑界面程序的打开方式都变成一种了,怎么还原啊?...
- python中函数的可变参数解析
- Spark2.x RPC解析
- AcWing之二维数组的查找
- 百度Java三面:现场面试39题目实拍含答案!