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.

Input

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 tij is the time the j-th painter needs to work on the i-th picture.

Output

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.

Examples
input

Copy
5 1
1
2
3
4
5
output

Copy
1 3 6 10 15 
input

Copy
4 2
2 5
3 1
5 3
10 1
output

Copy
7 8 13 21 

做题像是憋屎,想明白后,一下就出来了。
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <xfunctional>
#define ll long long
#define mod 998244353
using namespace std;
int dir[][] = { {,},{,-},{-,},{,} };
const int maxn = ;
const long long inf = 0x7f7f7f7f7f7f7f7f; int main()
{
int m, n;
cin >> m >> n;
vector<vector<int>> t(m+, vector<int>(n+,));
for (int i = ; i <= m; i++)
for (int j = ; j <= n; j++)
cin >> t[i][j];
for (int i = ; i <= m; i++)
{
for (int j = ; j <= n; j++)
{
if (t[i][j - ] < t[i - ][j])
t[i][j] += t[i - ][j];
else
t[i][j] += t[i][j - ];
}
}
for (int i = ; i <= m; i++)
{
cout << t[i][n] << " ";
}
return ;
}

Art Union的更多相关文章

  1. 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 ...

  2. Codeforces Round #241 (Div. 2) B. Art Union 基础dp

    B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Codeforces Round #241 (Div. 2) B. Art Union (DP)

    题意:有\(n\)个画家,\(m\)幅画,每个画家负责\(m\)幅画,只有前一个画家画完时,后面一个画家才能接着画,一个画家画完某幅画的任务后,可以开始画下一幅画的任务,问每幅画最后一个任务完成时的时 ...

  4. n个人作m幅画

    题目网址: http://codeforces.com/problemset/problem/416/B A well-known art union called "Kalevich is ...

  5. 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 ...

  6. The Art of Deception

    前言 一些黑客毁坏别人的文件甚至整个硬盘,他们被称为电脑狂人(crackers)或计算机破坏者(vandals).另一些新手省去学习技术的麻烦,直接下载黑客工具侵入别人的计算机,这些人被称为脚本小子( ...

  7. Android内存优化(一)DVM和ART原理初探

    相关文章 Android内存优化系列 Java虚拟机系列 前言 要学习Android的内存优化,首先要了解Java虚拟机,此前我用了多篇文章来介绍Java虚拟机的知识,就是为了这个系列做铺垫.在And ...

  8. SQL Server-聚焦UNIOL ALL/UNION查询(二十三)

    前言 本节我们来看看有关查询中UNION和UNION ALL的问题,简短的内容,深入的理解,Always to review the basics. 初探UNION和UNION ALL 首先我们过一遍 ...

  9. SQL 提示介绍 hash/merge/concat union

    查询提示一直是个很有争议的东西,因为他影响了sql server 自己选择执行计划.很多人在问是否应该使用查询提示的时候一般会被告知慎用或不要使用...但是个人认为善用提示在不修改语句的条件下,是常用 ...

随机推荐

  1. MySQL概述及入门(二)

    MySql概述及入门(二) MySQL架构 逻辑架构图: 执行流程图: MySQL的存储引擎 查询数据库支持的存储引擎 执行: show engines: 多存储引擎是mysql有别于其他数据库的一大 ...

  2. PyCharm2019 永久激活(测试通过)

    2019.1.1 专业版 永久期限,需要下载补丁,以及配置文件 补丁地址:https://pan.baidu.com/s/16ALpz_BCXjsRkpS_PtD23A 1,下载安装pycharm程序 ...

  3. web框架的基础原理

    http协议 HTTP简介 HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本 ...

  4. Redis的各个数据的类型基本命令

    什么是Redis: 概念: Redis (REmote DIctionary Server) 是用 C 语言开发的一个开源的高性能键值对(key-value)数据库. 特征:1. 数据间没有必然的关联 ...

  5. jquery-进度条

    function process_bar(s_date, e_date, data) { $('.modal-body').text('你选择的时期范围是:' + s_date + '到' + e_d ...

  6. 移动Web开发-WebApp(flex布局+移动端导航案例)

    实际开发中的像素:css像素设备像素比dpr=设备像素/css像素标清屏dpr=1 高清屏dpr=2缩放改变的是css像素大小PPI(每英寸的物理像素点)=根号(屏幕横向分辨率²+屏幕纵向分辨率²)/ ...

  7. ECMAScript基本对象——Date日期对象

    1.创建 var 对象名 = new Date(); 2.方法 ①toLocaleString()据本地时间格式,把 Date 对象转换为字符串.和电脑的语言位置有关 ②getTime()返回 197 ...

  8. P4802 [CCO 2015]路短最

    Problem 这题的题意是 求一条 经过 起点和终点的 最长路径.且一个点只能经过一次. 我们设定 \(dis_{i,j}\) 为 i 到 j 的距离(应该没有重边) 要注意的是 不能用 \(Flo ...

  9. I Hate It HDU - 1754 线段树 单点修改+区间最值

    #include<iostream> #include<cstring> using namespace std; ; int m,n,p; struct node{ int ...

  10. 洛谷p1980 计数问题

    题目描述 试计算在区间 111 到 nn n的所有整数中,数字x(0≤x≤9) x(0 ≤ x ≤ 9)x(0≤x≤9)共出现了多少次?例如,在 111到11 11 11中,即在 1,2,3,4,5, ...