A9398 | Art Union
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $t_{ij}$ 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.
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 $t_{ij}$ 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 $t_{i1},t_{i2},...,t_{in}$ ( $1<=t_{ij}<=1000$ ), where $t_{ij}$ is the time the $j$ -th painter needs to work on the $i$ -th picture.
输出格式
Print the sequence of $m$ integers $r_{1},r_{2},...,r_{m}$ , where $r_{i}$ is the moment when the $n$ -th painter stopped working on the $i$ -th picture.
输入输出样例
输入 #1
5 1 1 2 3 4 5
输出 #1
1 3 6 10 15
输入 #2
4 2 2 5 3 1 5 3 10 1
输出 #2
7 8 13 21
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted