ACboy needs your help

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2793    Accepted Submission(s): 1441 
Problem Description
ACboy 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
The 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.
 

Output
For each data set, your program should output a line which contains the number of the max profit ACboy will gain.
 

Sample Input
2 2 1 2 1 3 2 2 2 1 2 1 2 3 3 2 1 3 2 1 0 0
 

Sample Output
3 4 6
 

Source
 

Recommend
lcy
// 1A 看来我的想法还是没有问题的、、
// 因为同一类不能叠加更新,所以选取了 2个数组 ,然后就是 背包了
#include <iostream>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int A[][];
int dp1[],dp2[];
int main()
{
int n,m;
int in;
int i,j,k;
while(scanf("%d %d",&n,&m),n|m){ for(i=;i<=n;i++)
for(j=;j<=m;j++)
scanf("%d",&A[i][j]);
memset(dp1,,sizeof(dp1));
memset(dp2,,sizeof(dp2));
for(i=;i<=n;i++){
for(j=;j<=m;j++)
for(k=m;k>=j;k--){
if(dp2[k]<dp1[k-j]+A[i][j])
dp2[k]=dp1[k-j]+A[i][j];
}
for(j=;j<=m;j++)
dp1[j]=dp2[j];
}
printf("%d\n",dp1[m]); } return ;
}

hdu 1712 ACboy needs your help的更多相关文章

  1. HDU 1712 ACboy needs your help(包背包)

    HDU 1712 ACboy needs your help(包背包) pid=1712">http://acm.hdu.edu.cn/showproblem.php? pid=171 ...

  2. HDU 1712 ACboy needs your help 典型的分组背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 ACboy needs your help Time Limit: 1000/1000 MS ( ...

  3. hdu 1712 ACboy needs your help 分组背包

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...

  4. HDU 1712 ACboy needs your help (分组背包模版题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 有n门课,和m天时间.每门课上不同的天数有不同的价值,但是上过这门课后不能再上了,求m天里的最大 ...

  5. HDU 1712 ACboy needs your help(分组背包入门题)

    http://acm.hdu.edu.cn/showproblem.php?pid=1712 题意: 有个人学习n门课程,a[i][j]表示用j分钟学习第i门课程所能获得的价值,背包容量为一共有m时间 ...

  6. 分组背包 例题:hdu 1712 ACboy needs your help

    分组背包需求 有N件物品,告诉你这N件物品的重量以及价值,将这些物品划分为K组,每组中的物品互相冲突,最多选一件,求解将哪些物品装入背包可使这些物品的费用综合不超过背包的容量,且价值总和最大. 解题模 ...

  7. HDU 1712 ACboy needs your help(分组背包)

    题意:给你n的课程组,每个课程组有m个课程,每个课程有一个完成时间与价值.问在m天内每组课程组最多选择一个,这样可以得到的最大价值是多少 题解:分组背包,其实就是每个课程组进行01背包,再在课程组内部 ...

  8. HDU - 1712 - ACboy needs your help 【分组背包】

    <题目链接> 题目大意:有n个课程,现在花M天来学习这些课程,学习每个课程花的天数所得到的价值不同,求M天怎么分配学习才能得到的价值最大.(这些课程得到的价值和所花天数的关系由矩阵给出) ...

  9. HDU 1712 ACboy needs your help AC男需要你的帮助 (分组的背包)

    分组背包问题:有N件物品和一个容量为V的背包.第i件物品的体积是c[i],价值是w[i].这些物品被划分为若干组,每组中的物品互相冲突,最多选一件.求解将哪些物品装入背包可使这些物品的体积总和不超过背 ...

随机推荐

  1. Thinkcmf 在新浪云上的部署问题

    最近要开发一个社团主页,于是想到了CMF内容管理系统的,但是直接在自己的服务器测试成本太高,于是选择了在新浪云上进行部署测试. 但是在安装Thinkcmf的过程中产生了一些技术性的问题.但最后终于在自 ...

  2. SQLite3中自增主键

    SQLite清空表并将自增列归零 SQL标准中有TRUNCATE TABLE语句,用来清空表的所有内容. 但SQLite不支持这个语句.在SQLite中直接使用 DELETE FROM TableNa ...

  3. centos6.5安装配置LDAP服务[转]

    安装之前查一下 1 find / -name openldap* centos6.4默认安装了LDAP,但没有装ldap-server和ldap-client 于是yum安装 1 su root 2 ...

  4. 【WS-Federation】到底有多少公司在用WS-Federation

    到底有多少公司在用WS-Federation? sso先调用一个登录接口 获取一个token 然后再调用各种业务接口 如果是ssl token 直接暴露就行了 没有ssl 最好每次取一个token, ...

  5. Bootstrap 内核引用(一)

    方法一: Bootstrap CDN推荐 本站实例采用的是百度的静态资源库(http://cdn.code.baidu.com/)上的Bootstrap资源. 百度的静态资源库的 CDN 服务,访问速 ...

  6. selenium + python网页自动化测试环境搭建

    1.python的安装 ,这个不解释,exe文件运行安装即可,既然你选择python,相信你是熟悉python的,我安装目录C:\Python27 2.setuptools 的安装也非常简单,同样是e ...

  7. apache与nginx日志文件的区别(转载)

    apache与nginx日志文件的区别 转载:http://www.xfcodes.com/apache/log/3270.htm 导读:apache与nginx日志文件的区别,在apache与ngi ...

  8. C# SqlConnection

    public static ArrayList Connect(string connectionString, string commandText) { ArrayList retValList ...

  9. 【概率】BZOJ 3450:Tyvj1952 Easy

    Description 某一天WJMZBMR在打osu~~~但是他太弱逼了,有些地方完全靠运气:( 我们来简化一下这个游戏的规则 有n次点击要做,成功了就是o,失败了就是x,分数是按comb计算的,连 ...

  10. Partition an array around an interger

    Partition an array of integers around a value such taht all elements less than x come before element ...