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. 从HTML到node.js以及跨域问题的解决

    废话不多说,直接上代码 网页客户端 <!DOCTYPE html> <html> <head> <meta http-equiv="Content- ...

  2. css3神奇的圆角边框、阴影框及其图片边框

    css3圆角,建议IE10以上 如果border-radius 单位是百分比,则参考为自身宽高,因此当宽高不一致时,圆角为不规则形状 如果border-radius 为50%,则为椭圆:当宽高一致时, ...

  3. JavaScript自学笔记(2)---function a(){} 和 var a = function(){}的区别(javascript)

    function a(){} 和 var a = function(){}的区别: 学习做浮窗,看到别人的代码里有: window.onresize = function(){ chroX = doc ...

  4. 源码编译安装python2/3版本

    1- 源码编译安装python2.7版本 1.1- 下载源码包 wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz 1.2- ...

  5. ubuntu--- tracker/libdeepsort.so 找不到cv报错

    一.刚开始解决尝试:因为“删掉lib下的libdeepsort.so报错”,原先以为是 libdeepsort.so 需要拷贝到 /lib路径下的问题,可是因为后来的工程有的好使,又的不好使了.''' ...

  6. 吴裕雄--天生自然 python开发学习笔记:Git安装配置流程

  7. dubbox的小案例

    什么是Dubbox: Dubbo是一个被国内很多互联网公司广泛使用的开源分布式服务框架,即使从国际视野来看应该也是一个非常全面的SOA基础框架.作为一个重要的技术研究课题,在当当网根据自身的需求,为D ...

  8. 【Debian学徒记事】Debian快速呼出Terminal终端

    Debian快速呼出Terminal终端 书接上回,Debian已经安装完毕 失踪的Ctrl+Alt+T 安装完毕启动,我发现了剑很诡异的事,Ctrl+Alt+T居然失灵了 (在多次测试后发现,Deb ...

  9. STL-string用法

    #include <string> #include <iostream> #include <cstring> #include <algorithm> ...

  10. os常用讲解

    os.mkdir()创建单个不存在的空目录,无法创建多个或者已经存在的含有文件的同名目录 os.makedirs() 能够递归创建多个目录,如果目录已经存在即使都是空的或者目录已经存在且含有文件,则引 ...