HD1712ACboy needs your help(纯裸分组背包)
ACboy needs your help
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5589 Accepted Submission(s):
3043
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?
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.
which contains the number of the max profit ACboy will gain.
1 2
1 3
2 2
2 1
2 1
2 3
3 2 1
3 2 1
0 0
4
6
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX = ;
int n,m;
int dp[MAX],a[MAX][MAX];
int main()
{
while(scanf("%d%d", &n, &m) != EOF)
{
if(n == && m == )
break;
for(int i = ; i <= n; i++)
for(int j = ; j <= m; j++)
scanf("%d", &a[i][j]);
memset(dp, , sizeof(dp));
for(int i = ; i <= n; i++)
{
for(int j = m; j > ; j--)
{
for(int k = ; k <=m; k++)
{
if(j >= k)
dp[j] = max(dp[j], dp[j - k] + a[i][k]);
}
}
}
printf("%d\n", dp[m]);
}
return ;
}
HD1712ACboy needs your help(纯裸分组背包)的更多相关文章
- hdu4003详解(树形dp+多组背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4003 Find Metal Mineral Time Limit: 2000/1000 MS (Jav ...
- dp--分组背包 P1757 通天之分组背包
题目背景 直达通天路·小A历险记第二篇 题目描述 自01背包问世之后,小A对此深感兴趣.一天,小A去远游,却发现他的背包不同于01背包,他的物品大致可分为k组,每组中的物品相互冲突,现在,他想知道最大 ...
- ACboy needs your help-分组背包模板题
id=17676" target="_blank" style="color:blue; text-decoration:none">ACboy ...
- D - 英文题 (多组背包)
The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a gian ...
- HDU 3449 Consumer (背包问题之有依赖背包)
题目链接 Problem Description FJ is going to do some shopping, and before that, he needs some boxes to ca ...
- 【题解】洛谷P1273 有线电视网(树上分组背包)
次元传送门:洛谷P1273 思路 一开始想的是普通树形DP 但是好像实现不大好 观摩了一下题解 是树上分组背包 设f[i][j]为以i为根的子树中取j个客户得到的总价值 我们可以以i为根有j组 在每一 ...
- (第三场) A PACM Team 【dp,五维背包】
链接:https://www.nowcoder.com/acm/contest/141/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...
- hdu 3535 背包综合题
/* 有n组背包,每组都有限制 0.至少选一项 1.最多选一项 2.任意选 */ #include <iostream> #include <cstdio> #include ...
- HDU3535 AreYouBusy 混合背包
题目大意 给出几组物品的体积和价值,每组分为三种:0.组内物品至少选一个:1.组内物品最多选一个:2.组内物品任意选.给出背包容量,求所能得到的最大价值. 注意 仔细审题,把样例好好看完了再答题,否则 ...
随机推荐
- homepage左边的导航菜单怎么做的?
homepage左边的导航菜单怎么做的? 为啥只在homepage页面写了一个div 然后用一个homepage.js来填充这个div 然后用一个外部容器ID作为homepage.js的参数
- java读取文件批量插入记录
只是一个例子,方便以后查阅. import ey.db.oracle.OracleHelper; import ey.db.type.*; import java.io.BufferedReader; ...
- no.5.print sum
#-*-coding=utf-8-*- for a in range(1,50,1): for b in range(1,50,1): for c in range(1,50,1): if a+b+c ...
- [转]有关WorldWind1.4的worldwind.cs窗口设计器打开错误的解决方法
Solution for Designer error when opening WorldWind.cs in WW1.4.0 When I load the WW project in my Vi ...
- Java运算符优先级
序列号 符号 名称 结合性(与操作数) 目数 说明 1 . 点 从左到右 双目 ( ) 圆括号 从左到右 [ ] 方括号 从左到右 2 + 正号 从右到左 单目 - 负号 从右到左 单目 ++ ...
- js浮点数精确计算(加、减、乘、除)
<SPAN style="FONT-SIZE: 18px">//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显.这个函数返回较为精确的加 ...
- 20135220谈愈敏Linux Book_18
第18章 调试 调试内核艰难且风险高,关键在于对内核的深刻理解. 18.1 准备开始 需要的是: 一个bug 一个藏匿bug的内核版本 相关内核代码的知识和运气 内核中的bug不是很清晰,调试成功的关 ...
- libusb(.NET)开源项目使用小结
更多细节请参考官方帮助文档 1,修改设备类型为自己的标识 InfWizard项目里,改掉资源文件LibUsb-Win32-LUDN.Driver.Resources. 原来的三处libusb-win3 ...
- css中的伪类和伪元素
伪类用单冒号 我们平时熟悉的a:link.a:visited.a:hover和a : active 伪元素用双冒号(为了更好的兼容我们也用单冒号) 常用的:before :after和 :fir ...
- JAVA package-info文件【转】
翻看以前的笔记,看到一个特殊的java文件:pacakge-info.java,虽然有记录,但是不全,就尝试着追踪一下该问题, 分享一下流水账式的结果. 首先,它不能随便被创建.在Eclipse中, ...