ACboy needs your help(简单DP)
HDU 1712
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.
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
#define MX 105
int n,m;
int dp[MX][MX];
int A[MX][MX];
int main()
{
while (scanf("%d%d",&n,&m)&&(n||m))
{
memset(dp,,sizeof(dp));
memset(A,,sizeof(A));
for (int i=;i<=n;i++)
{
for (int j=;j<=m;j++)
scanf("%d",&A[i][j]);
}
for (int i=;i<=n;i++) // i 本书
{
for (int j=;j<=m;j++) // j 天
{
for (int k=;k<=j;k++)
{
dp[i][j]=max(A[i][k]+dp[i-][j-k],dp[i][j]);
}
}
}
printf("%d\n",dp[n][m]);
}
return ;
}
ACboy needs your help(简单DP)的更多相关文章
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Codeforces Round #260 (Div. 1) A. Boredom (简单dp)
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...
- codeforces Gym 100500H A. Potion of Immortality 简单DP
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
- 简单dp --- HDU1248寒冰王座
题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...
- poj2385 简单DP
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit ...
- hdu1087 简单DP
I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB ...
- poj 1157 LITTLE SHOP_简单dp
题意:给你n种花,m个盆,花盆是有顺序的,每种花只能插一个花盘i,下一种花的只能插i<j的花盘,现在给出价值,求最大价值 简单dp #include <iostream> #incl ...
- hdu 2471 简单DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=( dp[n-1][m],dp[n][m-1],d[i][k ...
- Codeforces 41D Pawn 简单dp
题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...
随机推荐
- account for 与led to和result in的区别
account for sth:be the explanation of sth; explain the cause of sth 作某事物的解释; 解释某事物的原因:His illness ac ...
- 利用yarn多队列实现hadoop资源隔离
大数据处理离不开hadoop集群的部署和管理,对于本来硬件资源就不多的创业团队来说,做好资源的共享和隔离是很有必要的,毕竟不像BAT那么豪,那么怎么样能把有限的节点同时分享给多组用户使用而且互不影响呢 ...
- MVC EasyUI 时间格式化
用 return Json(dr, JsonRequestBehavior.AllowGet); 会返回一个json 数据格式,在用 EasyUI 输出表格内容时会遇到时间输出不是我们想要的格式, ...
- Android面试题3之描写叙述下Android的系统架构
描写叙述下Android的系统架构: Android系统从下往上分为Linux内核层(linux kerner),执行库(runtime library),应用程序框架层,应用程序层 linuxker ...
- 载入本地Html文件
NSString * resousePath = [[NSBundle mainBundle]resourcePath]; NSString * filePath = [resouse ...
- Laravel之Eloquent ORM关联
一.一对一 1.主对从(hasOne) 从User模型中取出用户的手机 User模型中: /** * 获取关联到用户的手机 */ public function phone() { return $t ...
- Linux非阻塞IO(五)使用poll实现非阻塞的回射服务器客户端
前面几节我们讨论了非阻塞IO的基本概念.Buffer的设计以及非阻塞connect的实现,现在我们使用它们来完成客户端的编写. 我们在http://www.cnblogs.com/inevermore ...
- Oracle PLSQL通过SMTP发送E-MAIL邮件代码
登录到SMTPserver发送邮件,支持HTML CREATE OR REPLACE PROCEDURE send_mail( p_recipient VARCHAR2, -- 邮件接收 ...
- react-native 初始化 各种报错 及 解决方案
1.Unable to load script from assets 'index.android.bundle'. curl -k "http://localhost:8081/inde ...
- 苹果版小黄车(ofo)app主页菜单效果
代码地址如下:http://www.demodashi.com/demo/12823.html 前言: 最近又是公司项目上线一段时间了,又是到了程序汪整理代码的节奏了.刚好也用到了ofo主页菜单的效果 ...