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 ...
随机推荐
- golang: multiple http.writeHeader calls
背景: golang的http服务,读取文件,提供给client下载时候. 出现 multiple http.writeHeader calls 错误. func DownloadFile(w htt ...
- sails ORM组件 Waterline v0.10 英文文档
http://sailsdoc.swift.ren/ 这里有 sails中文文档 Introduction Installation Getting Started Models Data types ...
- 如何制作一款HTML5 RPG游戏引擎——第四篇,情景对话
今天我们来实现情景对话.这是一个重要的功能,没有它,游戏将变得索然无味.所以我们不得不来完成它. 但是要知道,使用对话可不是一件简单的事,因为它内部的东西很多,比如说人物头像,人物名称,对话内容... ...
- 基于python3.6.6的scrapy环境部署+图像识别插件安装
一.Python3.6.6安装1.安装依赖的二进制软件包yum -y install zlib zlib-devel bzip2 bzip2-devel ncurses ncurses-devel r ...
- Linux修改信息
修改时间 sudo date -s MM/DD/YY //修改日期 sudo date -s hh:mm:ss //修改时间 在修改时间以后,修改硬件CMOS的时间 sudo hwclock --sy ...
- cpu-》内存-》磁盘
cpu相当于计算机大脑负责计算以及发送执行命令:内存相当于人的记忆是临时存储:磁盘相当于笔记本,负责永久存储数据: 当系统需要调用硬盘当中的数据时,会将硬盘数据读入内存供cpu进行处理.cpu只会读取 ...
- 利用trigger同步Oracle数据库
oracle不同数据库之间进行同步数据时,可以用触发器来实现,但需要数据库A访问数据库B,那么可以通过创建数据连接来实现,代码如下: CREATE DATABASE LINK dblink_test ...
- HDU 1532 Drainage Ditches(网络流模板题)
题目大意:就是由于下大雨的时候约翰的农场就会被雨水给淹没,无奈下约翰不得不修建水沟,而且是网络水沟,并且聪明的约翰还控制了水的流速, 本题就是让你求出最大流速,无疑要运用到求最大流了.题中m为水沟数, ...
- hdu6206 Apple
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6206 题目: Apple Time Limit: 1000/1000 MS (Java/Oth ...
- hdu2328 Corporate Identity
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2328 题目: Corporate Identity Time Limit: 9000/3000 MS (J ...