Codeforces Round #241 (Div. 2) B. Art Union 基础dp
1 second
256 megabytes
standard input
standard output
A well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.
Each painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the first painter uses color 1, the second one uses color 2, and so on. Each picture will contain all these n colors. Adding the j-th color to the i-th picture takes the j-th painter tij units of time.
Order is important everywhere, so the painters' work is ordered by the following rules:
- Each picture is first painted by the first painter, then by the second one, and so on. That is, after the j-th painter finishes working on the picture, it must go to the (j + 1)-th painter (if j < n);
- each painter works on the pictures in some order: first, he paints the first picture, then he paints the second picture and so on;
- each painter can simultaneously work on at most one picture. However, the painters don't need any time to have a rest;
- as soon as the j-th painter finishes his part of working on the picture, the picture immediately becomes available to the next painter.
Given that the painters start working at time 0, find for each picture the time when it is ready for sale.
The first line of the input contains integers m, n (1 ≤ m ≤ 50000, 1 ≤ n ≤ 5), where m is the number of pictures and n is the number of painters. Then follow the descriptions of the pictures, one per line. Each line contains n integers ti1, ti2, ..., tin (1 ≤ tij ≤ 1000), where tijis the time the j-th painter needs to work on the i-th picture.
Print the sequence of m integers r1, r2, ..., rm, where ri is the moment when the n-th painter stopped working on the i-th picture.
5 1
1
2
3
4
5
1 3 6 10 15
4 2
2 5
3 1
5 3
10 1
7 8 13 21
思路:dp[i][t]=max(dp[i][t-1],dp[i-1][t])+a[i][t];
#include<bits/stdc++.h>
using namespace std;
#define ll __int64
#define mod 1000000007
#define esp 0.00000000001
const int N=5e4+,M=1e6+,inf=1e9;
int dp[N][];
int a[N][];
int main()
{
int x,y,z,i,t;
scanf("%d%d",&x,&y);
for(i=;i<=x;i++)
for(t=;t<=y;t++)
scanf("%d",&a[i][t]);
for(i=;i<=x;i++)
{
for(t=;t<=y;t++)
dp[i][t]=max(dp[i][t-],dp[i-][t])+a[i][t];
}
for(i=;i<=x;i++)
cout<<dp[i][y]<<" ";
return ;
}
Codeforces Round #241 (Div. 2) B. Art Union 基础dp的更多相关文章
- Codeforces Round #241 (Div. 2)->B. Art Union
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #241 (Div. 2) B. Art Union (DP)
题意:有\(n\)个画家,\(m\)幅画,每个画家负责\(m\)幅画,只有前一个画家画完时,后面一个画家才能接着画,一个画家画完某幅画的任务后,可以开始画下一幅画的任务,问每幅画最后一个任务完成时的时 ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #241 (Div. 2) B dp
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #241 (Div. 2)->A. Guess a number!
A. Guess a number! time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...
- Codeforces Round #164 (Div. 2) E. Playlist 贪心+概率dp
题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory ...
- Codeforces Round #265 (Div. 1) C. Substitutes in Number dp
题目链接: http://codeforces.com/contest/464/problem/C J. Substitutes in Number time limit per test 1 sec ...
- Codeforces Round #290 (Div. 2) D. Fox And Jumping dp
D. Fox And Jumping 题目连接: http://codeforces.com/contest/510/problem/D Description Fox Ciel is playing ...
随机推荐
- 011-Shell 文件包含
和其他语言一样,Shell 也可以包含外部脚本.这样可以很方便的封装一些公用的代码作为一个独立的文件. Shell 文件包含的语法格式如下: . filename # 注意点号(.)和文件名中间有一空 ...
- jenkins用户管理(Role-based Authorization Strategy插件使用)
安装:Role-based Authorization Strategy插件 一.点击左侧的"系统管理"-->再点击绿色的"管理插件" 二.点击&quo ...
- strtoul函数的使用
函数原型: unsigned long strtoul(const char *nptr,char **endptr,int base ) 参数1:字符串起始地址参数2:返回字符串有效数字的结束地址, ...
- PAT 1084 Broken Keyboard[比较]
1084 Broken Keyboard (20 分) On a broken keyboard, some of the keys are worn out. So when you type so ...
- 关于在MFC的视图类里面添加各种控件 以及给这些控件添加对用的函数。2015-03-24 13:46:00
首先我们把题目所示的要求分为两个问题: 问题一:如何给基于MFC的单文档视图类里面添加 控件.就是那种类似工具箱里面的控件. 问题二:如何给已经添加的控件 定义一些消息的响应函数. ××××××××× ...
- Java读取CSV和XML文件方法
游戏开发中,读取策划给的配置表是必不可少的,我在之前公司,策划给的是xml表来读取,现在公司策划给的是CSV表来读取,其实大同小异,也并不是什么难点,我就简单分享下Java如何读取XML文件和CSV文 ...
- XDU 1031
#include<stdio.h> #define maxn 1005 int c[maxn][maxn]; int gcd(int a,int b){ ?a:gcd(b,a%b); } ...
- zabbix 4.0 安装配置
1.安装软件包: 1.安装软件包: yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap ...
- spark restful 作业提交
spark1.4起,在启动master进程时候,同时会有一个restful的服务器,可以接受RESTFUL的请求, 以下是提交应用的示例 curl -X POST http://tssloginsig ...
- 并发队列ConcurrentLinkedQueue与阻塞队列LinkedBlockingQueue的区别
1. 介绍背景 在Java多线程应用中,队列的使用率很高,多数生产消费模型的首选数据结构就是队列. Java提供的线程安全的Queue可以分为阻塞队列和非阻塞队列,其中阻塞队列的典型例子是Block ...