E. 20210919初中组-画画

    Type: Default 1000ms 256MiB

20210919初中组-画画

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

现有 nn 个画家(编号从 11nn)去完成 mm (编号从 11mm)幅画,画画的规则是:

  1. 每个画家都需要在每幅画上作画
  2. 对于第i号画家,他作画j幅画的条件为:[1,i-1]的所有画家在j幅画上作画完成,同时第i号画家完成[1,j-1]之间所有的作画

00 时刻开始,求每幅画完成的最早时刻是多少?

Input Format

第一行包含两个正整数 m,nm,n ( 1m5×104,1n51\le m\le 5\times 10^4,1\le n\le 5 );

接下来的 mm 行,每行包含 nn 个数 ti1,ti2,...,tint_{i1},t_{i2},...,t_{in} ( 1tij10001\le t_{ij}\le 1000 ),这里 tijt_{ij} 表示第 jj 个画家需要在第 ii 幅画上画画的时间。

Output Format

仅有一行,包含 mm 个正整数 r1,r2,...,rmr_{1},r_{2},...,r_{m} ,这里 rir_{i} 表示第 i 幅画全部完成的时间。各数两两之间用一个空格分隔。

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 

Hint

数据范围:

​ 对于 10%10\% 的数据 m100,n=1m \le 100,n=1; ​ 对另外 20%20\% 的数据 m100,n=2m \le 100,n=2; ​ 对于另外的 70%70\% 数据 m50000,n5m \le 50000,n\le 5

Note

对于样例2的解释:

画的编号 1号画家完成作画时间 2号画家完成作画时间
1 2 7
2 5 8
3 10 13
4 20 21

所以,答案是7 8 13 21

测试

Not Attended
Status
Done
Rule
XCPC
Problem
9
Start at
2025-9-23 14:00
End at
2025-9-23 17:00
Duration
3 hour(s)
Host
Partic.
2