分组背包----HDU1712 ACboy needs your help
很简单的一道分组背包入门问题。不多解释了。
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int N,M,A[][];
int dp[]; inline int Max(int a,int b)
{
if(a>b) return a;
return b;
} int main()
{
while(scanf("%d%d",&N,&M),(N||M))
{
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<=j;k++)//dp[j-k]+
dp[j]=Max(dp[j],dp[k]+A[i][j-k]);
}
}
printf("%d\n",dp[M]);
}
return ;
}
分组背包----HDU1712 ACboy needs your help的更多相关文章
- P1757 通天之分组背包 / hdu1712 ACboy needs your help (分组背包入门)
P1757 通天之分组背包 hdu1712 ACboy needs your help hdu1712题意:A[i][j]表示用j天学习第i个课程能够得到A[i][j]的收益,求m天内获得的收益最大值 ...
- dp之分组背包hdu1712
题意:有n门课程,和m天时间,完成a[i][j]得到的价值为第i行j列的数字,求最大价值...... 思路:分组背包,就是第n门课程,可以做一天,可以做两天,但它们相斥,你做了一天,就不能再做一天.. ...
- 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 分组背包
最基础的分组背包~ #include <iostream> #include <cstdio> #include <cstdlib> #include <cs ...
- 【HDU1712】ACboy needs your help(分组背包)
将背包九讲往后看了看,学习了一下分组背包.来做几道入门题,试试手. #include <iostream> #include <cstring> #include <cs ...
- HDU1712:ACboy needs your help(分组背包)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1712 解释看这里:http://www.cnblogs.com/zhangmingcheng/p/3940 ...
- [hdu1712]ACboy needs your help分组背包
题意:一共$m$天,$n$门课程,每门课程花费$i$天得到$j$的价值,求最后获得的最大价值 解题关键:分组背包练习,注意循环的顺序不能颠倒 伪代码: $for$ 所有的组$k$ $for{\rm ...
- HDU1712 ACboy needs your help(分组背包)
每种课程学习不同天数可以获得不同价值,这可以看成一个组,那么题目就是分组背包的模板题了. 1 #include<cstdio> 2 #include<cstring> 3 #i ...
- ACboy needs your help(HDU 1712 分组背包入门)
ACboy needs your help Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
随机推荐
- 第17篇 shell编程基础(2)
shell study 1.Exit StatusIf the command executed successfully (or true), the value of $? is zero. If ...
- [翻译]Web开发牛人访谈:你们都在用什么?
小肥鱼译注:早上看到这篇文章,觉得内容甚是有趣.作者跟web开发方面的诸多大牛进行了交流,了解到他们的研究动向,从访谈中可以看到各种风格的开发者,有浏览器控,有设备控.我想,知道行业里的优秀成员在做些 ...
- maven help:system
lifecycle:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html bindings:ht ...
- 有趣的java小项目------猜拳游戏
package com.aaa; //总结:猜拳游戏主要掌握3个方面:1.人出的动作是从键盘输入的(System.in)2.电脑是随机出的(Random随机数)3.双方都要出(条件判断) import ...
- jdk8的扩展注解
对于注解(也被称做元数据),Java 8 主要有两点改进:类型注解和重复注解. 1.类型注解 1)Java 8 的类型注解扩展了注解使用的范围. 在java 8之前,注解只能是在声明的地方所使用,ja ...
- 2015 浙江省赛B Team Formation (技巧,动归)
Team Formation For an upcoming programming contest, Edward, the headmaster of Marjar University, is ...
- oracle 11g r2 rac到单实例的dg
oracle 11g r2 rac到单实例的dg 1 主备环境说明 rac环境--primary CentOS release 6.5 (Final)hostname rac1 rac2ip 10.* ...
- php各版本编译好的扩展模块下载地址
php各版本[,x86/64 v9/v11/v14 nts/ts]编译好的扩展模块下载地址: https://windows.php.net/downloads/pecl/releases/ ht ...
- CSS 透明
filter:alpha(opacity=60);-moz-opacity:0.5;opacity: 0.5;
- Python IO 多路复用 \协程
IO 多路复用 作用: 检测多个socket是否已经发生变化(是否已经连接成功/是否已经获取数据) 即(可读/可写) IO请求时 解决并发 : 单线程 def get_data(key): cl ...