ACboy needs your help

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3282    Accepted Submission(s): 1703

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
分组背包!....
 /*o1背包@龚细军*/
/*维度为2的01背包*/
#include<stdio.h>
#include<string.h>
#define maxn 102
int dp[maxn];
int aa[maxn][maxn]; int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
int m,n,i,j,k;
while(scanf("%d%d",&n,&m),m+n)
{
memset(dp,,sizeof(dp));
for(i=;i<=n;i++) // class
for(j=;j<=m;j++) //day
scanf("%d",&aa[i][j]);
//对每一门课程进行背包施放
for(i=;i<=n;i++)
{
for(j=m;j>=;j--) //代表的是背包的容量
{
for(k=;k<=j;k++) //在这个容量内选择一个房间去,和之前放进去的比较!
dp[j]=max(dp[j],dp[j-k]+aa[i][k]);
}
}
printf("%d\n",dp[m]);
}
return ;
}

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

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

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

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

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

  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

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. Eclipse 报 “Exception in thread "main" java.lang.OutOfMemoryError: Java heap space ”错误的解决办法

    1.打开Eclipse软件,选择菜单栏run,在二级菜单中选择 Debug Configurations...  项,如下图所示. 2.在弹出的窗口中选择 (x)=Arguments 选项卡,VM a ...

  2. R语言缺点

    R的优点:免费,开源,体积小.缺点:对大文本处理差,另外一个也在于开源,package如果出错,烦死你.当你跑比较大的simulation,对效率有要求的时候,有时还是不得不用C,这可能是10小时和1 ...

  3. [转载] java的书

    1. Java 语言基础 谈到Java 语言基础学习的书籍,大家肯定会推荐Bruce Eckel 的<Thinking in Java >.它是一本写的相当深刻的技术书籍,Java 语言基 ...

  4. [leetcode]Remove Nth Node From End of List @ Python

    原题地址:http://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/ 题意: Given a linked list, remo ...

  5. JDBC具体解释(2)

    1.载入驱动程序. 注冊驱动程序有多方法,Class.forName();是一种显式地载入.当一个驱动程序类被Classloader装载后,在溶解的过程中,DriverManager会注冊这个驱动类的 ...

  6. word 文档如何加密

    给Word文档加密主要有以下几个方法:文件加密文件菜单设置:1.打开需要加密的Word文档.2.选“文件”的“另存为”,出现“另存为”对话框,在“工具”中选“常规选项”,出现“保存”选项卡.3.分别在 ...

  7. 【python】理想论坛爬虫长贴版1.00

    理想论坛有些长贴,针对这些长贴做统计可以知道某ID什么时段更活跃. 爬虫代码为: #---------------------------------------------------------- ...

  8. (算法)Trapping Rain Water II

    题目: Given n * m non-negative integers representing an elevation map 2d where the area of each cell i ...

  9. 【Android 百度地图实战】1.构建一个基础的地图页面

    虽然很简单,但是还是有些细节要注意的,小错误搞死人啊,具体步骤官网API已提供,地址在这. 效果图如下: 主要代码: package yc.example.yc_ebaidumap; import a ...

  10. web应用程序访问串口

    https://github.com/tylermenezes/SerialServe https://github.com/straend/SerialWebsocket http://www.cn ...