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

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
 
 
#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的更多相关文章

  1. hdu1712 分组背包

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1712 题意:有n门课程,和m天时间,完成mp[i][j]得到的价值为第i行j列的数字,求最 ...

  2. 简单分组背包ACboy needs your help(hdu1712)

    题意:有n个任务,完成期限是m天,a[i][j]代表第i个任务用j天完成可以获得的利益,问在这m天里面可以获得的最大利益,每次只能做一个任务,即多个任务不能同时做; 分析;用dp[i][j]代表在做第 ...

  3. P1757 通天之分组背包 / hdu1712 ACboy needs your help (分组背包入门)

    P1757 通天之分组背包 hdu1712 ACboy needs your help hdu1712题意:A[i][j]表示用j天学习第i个课程能够得到A[i][j]的收益,求m天内获得的收益最大值 ...

  4. HDU1712:ACboy needs your help(分组背包模板)

    http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem Description ACboy has N courses this term, an ...

  5. hdu1712 ACboy needs your help 分组背包

    最基础的分组背包~ #include <iostream> #include <cstdio> #include <cstdlib> #include <cs ...

  6. 【HDU1712】ACboy needs your help(分组背包)

    将背包九讲往后看了看,学习了一下分组背包.来做几道入门题,试试手. #include <iostream> #include <cstring> #include <cs ...

  7. HDU1712:ACboy needs your help(分组背包)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1712 解释看这里:http://www.cnblogs.com/zhangmingcheng/p/3940 ...

  8. 分组背包----HDU1712 ACboy needs your help

    很简单的一道分组背包入门问题.不多解释了. #include <iostream> #include <cstdio> #include <cstring> usi ...

  9. [hdu1712]ACboy needs your help分组背包

    题意:一共$m$天,$n$门课程,每门课程花费$i$天得到$j$的价值,求最后获得的最大价值 解题关键:分组背包练习,注意循环的顺序不能颠倒 伪代码: $for$ 所有的组$k$   $for{\rm ...

随机推荐

  1. pyinstaller打包后的exe退出时,类中的__del__不执行问题

    关于pyinstaller打包后的exe退出时,类中的__del__不执行问题,完善中

  2. burpsuite 出现 ssl_error_no_cypher_overlap

    解决方案一:1.浏览器地址栏输入 about:config2.查找 security.tls.version.fallback-limit 和 security.tls.version.min,并将值 ...

  3. 关于package.json学习

    1.如果要下载npm包,必须有package.json文件,不然会报错,如果缺少必要字符报错,参考报错信息 2.license,指定用户权限,可以不写,不会报错 3.devDependencies,依 ...

  4. 3、SpringBoot------邮件发送(1)

    开发工具:STS 代码下载链接:https://github.com/theIndoorTrain/Springboot/tree/8878e8e89ce01ceb967ef8c1193ac740a6 ...

  5. 【iOS】史上最全的iOS持续集成教程 (下)

    :first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdow ...

  6. http状态码有那些,分别代表什么意思

    http1.0和2.0的区别https://blog.csdn.net/linsongbin1/article/details/54980801/ 简单版:         100  Continue ...

  7. 经典sql语句汇总

    1,某条数据放首位,其他倒序并分页 select * from Student order by( case     when id='2'  then 1 ELSE 4 END),id desc l ...

  8. Gson转Map时,Int会变成double解决方法

    package com.cdy.demo; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; ...

  9. [USACO5.1]夜空繁星Starry Night

    题目背景 高高的星空,簇簇闪耀的群星形态万千.一个星座(cluster)是一群连通的星组成的非空连通星系,这里的连通是指水平,垂直或者对角相邻的两个星星.一个星座不能是另一个更大星座的一部分, 星座可 ...

  10. POJ:3268-Silver Cow Party

    Silver Cow Party Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 26184 Accepted: 11963 De ...