动态规划:HDU1712-ACboy needs your help(分组背包问题)
ACboy needs your help
Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 4 Accepted Submission(s) : 1
profit?
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.
1 2
1 3
2 2
2 1
2 1
2 3
3 2 1
3 2 1
0 0
4
6
for 所有的组k
for v = V...0
for 所有i组的k
f[v]=max{f[v],f[v-c[i]]+w[i]}
/*
之前在做这个题的时候看了一个人的博客,他把公式给写反了,v...V写到内层去了,
弄得一直WA,也是无语了,在这个博客里面纠正一下这个错误
*/ #include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+100;
const int maxn2 = 1e2+10;
int maps[maxn2][maxn2];
int dp[maxn];
struct NUM
{
int va,cost;
}num[maxn];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m) && n+m)
{
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&maps[i][j]); for(int i=1;i<=n;i++)
for(int j=m;j>=1;j--)
for(int k=1;k<=j;k++)
dp[j] = max(dp[j],dp[j-k]+maps[i][k]);
printf("%d\n",dp[m]);
}
}
动态规划:HDU1712-ACboy needs your help(分组背包问题)的更多相关文章
- HDU1712:ACboy needs your help(分组背包模板)
http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem Description ACboy has N courses this term, an ...
- [hdu1712]ACboy needs your help分组背包
题意:一共$m$天,$n$门课程,每门课程花费$i$天得到$j$的价值,求最后获得的最大价值 解题关键:分组背包练习,注意循环的顺序不能颠倒 伪代码: $for$ 所有的组$k$ $for{\rm ...
- hdu1712 ACboy needs your help 分组背包
最基础的分组背包~ #include <iostream> #include <cstdio> #include <cstdlib> #include <cs ...
- P1757 通天之分组背包 / hdu1712 ACboy needs your help (分组背包入门)
P1757 通天之分组背包 hdu1712 ACboy needs your help hdu1712题意:A[i][j]表示用j天学习第i个课程能够得到A[i][j]的收益,求m天内获得的收益最大值 ...
- ACboy needs your help hdu 分组背包问题
Description ACboy has N courses this term, and he plans to spend at most M days on study.Of course,t ...
- 分组背包----HDU1712 ACboy needs your help
很简单的一道分组背包入门问题.不多解释了. #include <iostream> #include <cstdio> #include <cstring> usi ...
- HDU1712 ACboy needs your help(分组背包)
每种课程学习不同天数可以获得不同价值,这可以看成一个组,那么题目就是分组背包的模板题了. 1 #include<cstdio> 2 #include<cstring> 3 #i ...
- hdu 1712 ACboy needs your help 分组背包
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...
- HDU 1712 ACboy needs your help (分组背包模版题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 有n门课,和m天时间.每门课上不同的天数有不同的价值,但是上过这门课后不能再上了,求m天里的最大 ...
随机推荐
- launchctl
Launchctl 系统启动时, 系统会以root用户的身份扫描/System/Library/LaunchDaemons和/Library/LaunchDaemons目录, 如果文件中有Disabl ...
- OracleJDK与OpenJDK的区别和联系
OpenJDK原是SunMicrosystems公司为Java平台构建的Java开发环境(JDK)的开源版本,完全自由,开放源码.OracleJDK里面包含的JVM是HotSpotVM,HotSpot ...
- Composition or inheritance for delegating page methods?
引用链接:http://watirmelon.com/2011/01/24/composition-or-inheritance-for-delegating-page-methods/ Compos ...
- Day1下午
T1 暴力50分 排A和B X,不用考虑X 用数组80分, 权值线段树.平衡树100, 一个函数? T2 打表 dp logn+1,+ 搜索,dp? txt..... T3 30分暴力和尽量均 ...
- spring数组注入
数组注入 public class MyCollection { private String[]array; private List<String>list; ...
- Day6 盒模型
Day6 盒模型 1.一.标准盒模型(w3c盒模型) 1)组成部分: content + padding + border + margin 内容 ...
- The sixth day
bound to 铁定You are bound to be fired 你会被铁定开除的 A:Dan forgot his map? Dan忘了带地图了吗? B:Yep!And he's boun ...
- 功放TAS5719耳机POP noise分析 对策
驱动功放时,遇到POP noise 是常见的问题,以前遇到此问题,首先想到的对策就是mute the output.本人一直来对此种解法感觉不爽,心里不快.最近遇到开机时耳机有很强的POP,决定好好研 ...
- .net密码找回
using System; using System.Collections.Generic; using System.Text; using System.Net.Mail; using Syst ...
- linux打开进程数测试
查看linux默认打开最大打开进程数 具体参考:https://www.jb51.net/article/143667.htm #include <unistd.h> #include & ...