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.组内物品任意选.给出背包容量,求所能得到的最大价值. 注意 仔细审题,把样例好好看完了再答题,否则 ...
随机推荐
- Gitblit-Git版本服务器环境部署
Gitblit介绍 Gitblit 是一个纯 Java 库用来管理.查看和处理 Git 资料库.相当于 Git 的 Java 管理工具,支持linux系统. Git是分布式版本控制系统,它强调速度.数 ...
- C# winform版 nbtstat
参考:http://www.cnblogs.com/geqinggao/archive/2013/01/21/2869644.html 一.nbtstat命令 显示基于 TCP/IP 的 NetBIO ...
- C语言 百炼成钢2
//题目4:输入某年某月某日,判断这一天是这一年的第几天? #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<st ...
- [转]仿World Wind构造自己的C#版插件框架——WW插件机制精简改造
很久没自己写东西啦,早该好好总结一下啦!一个大师说过“一个问题不应该被解决两次!”,除了一个好脑筋,再就是要坚持总结. 最近需要搞个系统的插件式框架,我参照World Wind的插件方式构建了个插件框 ...
- PHP基础20:创建文件
<?php /* 1.PHP 创建文件 - fopen() fopen() 函数也用于创建文件.也许有点混乱,但是在 PHP 中,创建文件所用的函数与打开文件的相同 如果您用 fopen() 打 ...
- Brief introduce to Iometer
<本人原创,纯粹为了练习英文博客的写作.转载请注明出处谢谢!非技术博客 http://shiyanch.lofter.com/ > *:first-child { margin-top: ...
- [CareerCup] 6.4 Blue Eyes People on Island 岛上的蓝眼人
6.4 A bunch of people are living on an island, when a visitor comes with a strange order: all blue-e ...
- LeetCode:Pascal's Triangle I II
LeetCode:Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For examp ...
- Itextsharp下根据Echarts图像生成pdf
本文介绍如何在C#中使用ItextSharp生成带echarts图表的pdf 一.生成一个简单的pdf 后台代码 publicActionResultGetPdf() { MemoryStream m ...
- 【开源】XPShadow, 用阴影让UWP更有层次感
UWP采用的是纯扁平化的设计,个人感觉极端了点,整个世界都是平的,导致App分不清层次,看不出重点.其实扁平化是趋势,android, ios都在搞,问题是android, ios都可以很轻松的实现阴 ...