hdu1712 ACboy needs your help 分组背包
最基础的分组背包~
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
int dp[], a[][];
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin );
#endif // ONLINE_JUDGE
int n,m;
while (~scanf("%d%d",&n,&m)&&(n||m))
{
for (int i=;i<=n;++i)
{
for (int j=;j<=m;++j) scanf("%d",&a[i][j]);
}
memset(dp,,sizeof(dp));
for (int i=;i<=n;++i)
{
for (int v=m;v>=;--v)
{
for (int j=;j<=v;++j)
{
dp[v]=max(dp[v],dp[v-j]+a[i][j]);
}
}
}
printf("%d\n",dp[m]);
}
return ;
}
没什么可说的。1Y
hdu1712 ACboy needs your help 分组背包的更多相关文章
- HDU1712:ACboy needs your help(分组背包模板)
http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem Description ACboy has N courses this term, an ...
- [hdu1712]ACboy needs your help分组背包
题意:一共$m$天,$n$门课程,每门课程花费$i$天得到$j$的价值,求最后获得的最大价值 解题关键:分组背包练习,注意循环的顺序不能颠倒 伪代码: $for$ 所有的组$k$ $for{\rm ...
- HDU 1712 ACboy needs your help (分组背包模版题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 有n门课,和m天时间.每门课上不同的天数有不同的价值,但是上过这门课后不能再上了,求m天里的最大 ...
- hdu 1712 ACboy needs your help 分组背包
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...
- P1757 通天之分组背包 / hdu1712 ACboy needs your help (分组背包入门)
P1757 通天之分组背包 hdu1712 ACboy needs your help hdu1712题意:A[i][j]表示用j天学习第i个课程能够得到A[i][j]的收益,求m天内获得的收益最大值 ...
- 【HDU1712】ACboy needs your help(分组背包)
将背包九讲往后看了看,学习了一下分组背包.来做几道入门题,试试手. #include <iostream> #include <cstring> #include <cs ...
- HDU1712:ACboy needs your help(分组背包)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1712 解释看这里:http://www.cnblogs.com/zhangmingcheng/p/3940 ...
- 分组背包----HDU1712 ACboy needs your help
很简单的一道分组背包入门问题.不多解释了. #include <iostream> #include <cstdio> #include <cstring> usi ...
- HDU1712 ACboy needs your help(分组背包)
每种课程学习不同天数可以获得不同价值,这可以看成一个组,那么题目就是分组背包的模板题了. 1 #include<cstdio> 2 #include<cstring> 3 #i ...
随机推荐
- Android在Eclipse上的环境配置
哈哈,首先转一个:https://my.oschina.net/fusxian/blog/293935 谢谢分享者 1.android SDK安装出现Failed to fetch URL http: ...
- mac 安装memcached服务
使用homebrew安装,homebrew安装方法http://brew.sh/ 安装memcached服务 brew install memcached 配置开机启动(用brew安装之后下面会提示怎 ...
- FZU 2082 过路费
树链剖分模板题 #include <cstdio> #include <iostream> #include <cstring> #include <algo ...
- Section 1.4 Packing Rectangles
本来是USACO Training的1.4.1的,但是介于今早过了食物链想起了这道题实在是太怨念了,翻出自己写的AC程序居然有5KB!! 思路很简单,枚举,而且就图中的六种情况.但是第六种变化状况太多 ...
- matlab图像剪裁命令imcrop()
调用格式: I2=imcrop(I,RECT): X2=imcrop(X,MAP,RECT): RGB2=imcrop(RGB,RECT): 其中,I.X.RGB分别对应灰度图像.索引图像.RGB图像 ...
- .net异常小总
1. ExecuteReader:CommandText属性尚未初始化 即:没有对sqlCommand对象的CommandText属性赋值,即没有写sql语句. 2. 由于代码已经过优化或者本机框 ...
- SharePoint 2016 的新特性概览(二)(What's New for IT Professionals in SharePoint Server 2016)
博客地址:http://blog.csdn.net/FoxDave SharePoint 2016 的新特性 三. 监测和数据(Insights and Data) 实时数据监测,包括对使用情况.存储 ...
- 《Head First设计模式(中文版)》
<Head First设计模式(中文版)>共有14章,每章都介绍了几个设计模式,完整地涵盖了四人组版本全部23个设计模式.前言先介绍<Head First设计模式(中文版)>的 ...
- JS 基于面向对象的 轮播图2
<script> // 函数不能重名, --> 子函数 // is defined function --> 函数名是否写错了 function AutoTab(id) { T ...
- UIkit框架之UIbutton的使用
1.UIbutton的继承关系:UIcontroller:UIview:UIresponder:NSObject: 2.添加按钮的步骤: (1)创建按钮的时候首先设置类型 (2)添加标题或者图片,设置 ...