ACboy needs your help

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

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

题意:

给你一个n*m的矩阵,行代表第i门课程,列代表修这门课程要花的时间天数,矩阵值代表得到的效益,输出最大效益。

输入:

输入n,m后输入n行m列的数代表效益

#include <iostream>
#include <cstring>
using namespace std;
int n,m;
int a[][];
int f[];
int main()
{
while(cin>>n>>m)
{
if(n==&&m==)
break;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
cin>>a[i][j];
memset(f,,sizeof(f));
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]);
cout<<f[m]<<endl;
}
return ;
}

HDU1712ACboy needs your help【分组背包】的更多相关文章

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

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

  2. Codeforces Round #383 (Div. 2) D 分组背包

    给出一群女孩的重量和颜值 和她们的朋友关系 现在有一个舞台 ab是朋友 bc是朋友 ac就是朋友 给出最大承重 可以邀请这些女孩来玩 对于每一个朋友团体 全邀请or邀请一个or不邀请 问能邀请的女孩的 ...

  3. HDU 3033 分组背包变形(每种至少一个)

    I love sneakers! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDU 1712 分组背包

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

  5. Codeforces Round #383 (Div. 2) D. Arpa's weak amphitheater and Mehrdad's valuable Hoses(分组背包+dsu)

    D. Arpa's weak amphitheater and Mehrdad's valuable Hoses Problem Description: Mehrdad wants to invit ...

  6. HDU3535AreYouBusy[混合背包 分组背包]

    AreYouBusy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. POJ1837 Balance[分组背包]

    Balance Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13717   Accepted: 8616 Descript ...

  8. Codevs1378选课[树形DP|两种做法(多叉转二叉|树形DP+分组背包)---(▼皿▼#)----^___^]

    题目描述 Description 学校实行学分制.每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分.学校开设了N(N<300)门的选修课程,每个学生可选课程的数量M是给定的.学生选修 ...

  9. hdu1712 分组背包

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

  10. Codeforces Round #383 (Div. 2) A,B,C,D 循环节,标记,暴力,并查集+分组背包

    A. Arpa’s hard exam and Mehrdad’s naive cheat time limit per test 1 second memory limit per test 256 ...

随机推荐

  1. linux的chmod命令

    chmod命令用来变更文件或目录的权限.在UNIX系统家族里,文件或目录权限的控制分别以读取.写入.执行3种一般权限来区分,另有3种特殊权限可供运用.用户可以使用chmod指令去变更文件与目录的权限, ...

  2. 【后台管理系统】—— Ant Design Pro入门学习&项目实践笔记(三)

    前言:前一篇记录了[后台管理系统]目前进展开发中遇到的一些应用点,这一篇会梳理一些自己学习Ant Design Pro源码的功能点.附:Ant Design Pro 在线预览地址. Dashboard ...

  3. linux基础教程---设置文件的主人、组别

    我们在操作linux的是要告诉文件是属于哪个主人的,哪个组别的.这样我们就须要知道该怎样设置": 设置文件的主人.组别 chown: change owner >chown    主人 ...

  4. 表单提交时上传图片 表单ajax提交

    页面 <script type="text/javascript" src="js/jquery.form.js"></script>& ...

  5. 输入N,打印如图所看到的的三角形(例:N=3,N=4,N=5)1&lt;=N&lt;=26

    package demo; public class PrintDemo { public static void main(String[] args) { print(26); } private ...

  6. paypal - 支付所遇到的问题,编码等等

    1.ipn支付方式编码问题,paypal默认编码为 gb2312,需要登录paypal后台,进入用户信息设置>销售工具>更多销售工具>paypal按钮编码设置>更多选项,全部修 ...

  7. 什么是SAAS模式网站?

    说到“SAAS”,它的读法非常有趣,有“萨斯”,有“S.A.A.S”, 还有中文白话“啥事”的.不过,大多不熟悉的朋友第一反应可能是非典?,别误会,此“SAAS”非彼“SARS”,一字之差,但是意义完 ...

  8. postman --发送json请求

    转自: http://blog.csdn.net/wangjun5159/article/details/47781301 简介: postman是一个很好的http模拟器,在测试rest服务时是很好 ...

  9. unity, 显示像素图,以及iOS下像素图变模糊解决办法

    在PS里画了个16x16像素的图: 在webplayer下Filter Mode选为Point,显示效果为: 在ios下显示效果为: 是由于iOS下会将图片压缩为pvr所致,想得到清晰的效果,需将Fo ...

  10. 基于Verilog的以2为底取对数函数log2(x)

    参考资料:xilinx AXI4 Stream Peripherals 源码 //*********************************************************** ...