hdu1712 分组背包 ACboy needs your help
ACboy needs your help
Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5022    Accepted Submission(s): 2714
has N courses this term, and he plans to spend at most M days on
study.Of course,the profit he will gain from different course depending
on the days he spend on it.How to arrange the M days for the N courses
to maximize the profit?
input consists of multiple data sets. A data set starts with a line
containing two positive integers N and M, N is the number of courses, M
is the days ACboy has.
Next follow a matrix A[i][j],
(1<=i<=N<=100,1<=j<=M<=100).A[i][j] indicates if ACboy
spend j days on ith course he will get profit of value A[i][j].
N = 0 and M = 0 ends the input.
1 2
1 3
2 2
2 1
2 1
2 3
3 2 1
3 2 1
0 0
4
6
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[][];
int f[];
int main(){
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
if(n==&&m==)
break;
memset(f,,sizeof(f));
memset(a,,sizeof(a));
for(int i=;i<=n;i++){
for(int j=;j<=m;j++)
scanf("%d",&a[i][j]);
} for(int i=;i<=n;i++){
for(int j=m;j>=;j--){
for(int k=;k<=j;k++)
f[j]=max(f[j],f[j-k]+a[i][k]);
}
}
printf("%d\n",f[m]);
}
return ;
}
hdu1712 分组背包 ACboy needs your help的更多相关文章
- hdu1712 分组背包
		题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1712 题意:有n门课程,和m天时间,完成mp[i][j]得到的价值为第i行j列的数字,求最 ... 
- 简单分组背包ACboy needs your help(hdu1712)
		题意:有n个任务,完成期限是m天,a[i][j]代表第i个任务用j天完成可以获得的利益,问在这m天里面可以获得的最大利益,每次只能做一个任务,即多个任务不能同时做; 分析;用dp[i][j]代表在做第 ... 
- 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(分组背包模板)
		http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem Description ACboy has N courses this term, an ... 
- hdu1712 ACboy needs your help    分组背包
		最基础的分组背包~ #include <iostream> #include <cstdio> #include <cstdlib> #include <cs ... 
- 【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分组背包
		题意:一共$m$天,$n$门课程,每门课程花费$i$天得到$j$的价值,求最后获得的最大价值 解题关键:分组背包练习,注意循环的顺序不能颠倒 伪代码: $for$ 所有的组$k$ $for{\rm ... 
随机推荐
- ipython notebook的使用
			刚开始使用python,用的是ipython notebook,感觉很好用. 写的程序主要是处理文件的,读写txt文件,生成xml文件,其中参考http://www.cnblogs.com/wangs ... 
- Java分享笔记:Map集合(接口)的基本方法程序演示
			package pack02; import java.util.*; public class MapDemo { public static void main(String[] args) { ... 
- Delphi 编写DLL动态链接库文件的知识
			一.DLL动态链接库文件的知识简介: Windows的发展要求允许同时运行的几个程序共享一组函数的单一拷贝.动态链接库就是在这种情况下出现的.动态链接库不用重复编译或链接,一旦装入内存,Dlls函数可 ... 
- IO流的应用_Copy文件
			IO流的应用_Copy文件 (1) import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundEx ... 
- AWS CentOS7 实例修改主机名
			问题描述: AWS EC2 实例在升级到CentOS7以后,我们发现主机名的修改不再像之前的版本(CentOS 5/6)一样简单. 每次新建实例之后,修改好主机名,重启或者克隆之后的机器,主机名还是会 ... 
- Linux平台下安装MySQL
			1.下载RPM包 http://dev.mysql.com/downloads/mysql/5.5.html#downloads 选择[Red Hat & Oracle Enterprise ... 
- C语言进阶——循环语句07
			循环语句的基本工作方式: 通过条件表达式判定是否执行循环体 条件表达式遵循if语句表达式的原则 do,while,for的区别: do语句先执行后判断,循环体至少执行一次 while语句先判断后执行, ... 
- [Link-Cut-Tree][BZOJ2631]Tree
			题面 Description: 一棵\(n\)个点的树,每个点的初始权值为\(1\).对于这棵树有\(q\)个操作,每个操作为以下四种操作之一: + u v c:将\(u\)到\(v\)的路径上的点的 ... 
- python基础之流程控制、数字和字符串处理
			流程控制 条件判断 if单分支:当一个“条件”成立时执行相应的操作. 语法结构: if 条件: command 流程图: 示例:如果3大于2,那么输出字符串"very good" ... 
- CodeForces 785C Anton and Fairy Tale 二分
			题意: 有一个谷仓容量为\(n\),谷仓第一天是满的,然后每天都发生这两件事: 往谷仓中放\(m\)个谷子,多出来的忽略掉 第\(i\)天来\(i\)只麻雀,吃掉\(i\)个谷子 求多少天后谷仓会空 ... 
