SDUT2857:艺术联合会(简单dp)
链接: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2857
题目解析:
这是去年校赛的题目,当时没做出来,现在才补,真水,这题就是一个简单dp。
看第k个人画第m幅画的时候,要考虑两个时间,1.第k-1个人画完第m幅画的时间,2.第k个人画完第m-1幅画的时间。
这两个时间的最大者+t[m][k]就是第k个人画完第m幅画的时间。
代码如下:
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <queue>
#define inf 0x3f3f3f3f
typedef long long ll;
#define eps 1e-9
using namespace std;
int n,m,t[][];
int dp[][];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(t,,sizeof(t));
scanf("%d%d",&m,&n);
for(int i=; i<=m; i++)
{
for(int j=; j<=n; j++)
{
scanf("%d",&t[i][j]);
}
}
memset(dp,,sizeof(dp));
for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{
dp[j][i]=max(dp[j][i],(max(dp[j][i-],dp[j-][i])+t[j][i]));
}
}
printf("%d",dp[][n]);
for(int i=; i<=m; i++)
printf(" %d",dp[i][n]);
printf("\n");
}
return ;
}
SDUT2857:艺术联合会(简单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 每一个格子仅仅 ...
随机推荐
- 原生Orcale数据库连接
package tj.test.demo; import java.sql.Connection;import java.sql.DriverManager;import java.sql.Prepa ...
- android 开发之hello world!
http://blog.sina.com.cn/s/blog_4e08922b0100nh6e.html http://blog.csdn.net/poechant/article/details/7 ...
- Yii2.0实现微信公众号后台开发
接入微信 Yii2后台配置 1.在app/config/params.php中配置token参数 return [ //微信接入 'wechat' =>[ 'token' => 'your ...
- hdu 1058:Humble Numbers(动态规划 DP)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- 【cb2】扩展硬盘
1.硬盘为sata串口 2.参考 http://docs.cubieboard.org/tutorials/ct1/installation/moving_rootfs_from_nandflash_ ...
- (转)The windows boot configuration data file dose not contain a valid OS entry
开价蓝屏,显示: Windows failed to start. A recent hardware or software change might be the case.to fix the ...
- VS------快捷键一览
1. 属性封装快捷键:Ctrl + R + E
- 复习及总结--.Net线程篇(1)
老是没耐心写这些东西,最近想想也工作两年了,该对自己的东西做个整理了,不知道这次能坚持写几篇,总得来说尽量督促自己吧 言归正传,.net中的多线程主要可以使用两种方法进行调用 1,异步调用 2,Thr ...
- 5个基于Linux命令行的文件下载和网站浏览工具
导读 命令行是GNU/Linux中最神奇迷人的部分,它是非常强大的工具;命令行本身功能多样,多种内建或者第三方的命令行应用使得Linux变得更加健壮和强大.Linux Shell支持多种不同类型的网络 ...
- ListView.setDivider,自定义的Devider
ListView lv = getListView(); ColorDrawable sage = new ColorDrawable(this.getResources().getColor(R.c ...