Bottles

시간 제한1초메모리 제한2048 MB

요약
각 주자가 1km 구간마다 보내는 시간이 주어질 때, 각 구간 안에 동시에 있는 주자 수의 최댓값을 구해 출력한다.
난이도

보통10점 중 5점

유형
시뮬레이션, 정렬, 누적 합
정답자
아직 제출이 없습니다

문제

In the famous ICPC race, nn runners will participate. The course is mm kilometers long and for safety, it is divided into mm ranges. Each range is one kilometer long and Range ii (1≤i≤m1 ≤ i ≤ m) is the interval (i−1,i)(i - 1, i), which is the section between i−1i - 1 km and ii km from the starting point. We will ignore the case where the distance between the starting point and a runner is an integer. As the weather is quite hot, the organizers would like to put enough water. They will maintain a certain number of water bottles in each range. When a runner takes one bottle, they will put another immediately. They have found that the optimal number of water bottles could be obtained by calculating the maximum number of runners in that interval during the race. Based on the previous records of each runner, they have estimated how many seconds he/she will spend in each range.

Consider the following example. There are three runners, and the length of the course is six kilometers. The table shows the amount of time runners will spend in each range (in seconds).

RunnerRange 11Range 22Range 33Range 44Range 55Range 66
11350350s360360s370370s380380s390390s400400s
22240240s240240s240240s240240s240240s240240s
33480480s480480s520520s600600s600600s600600s

Now we will check the number of runners in each range during the race. Intentionally, the table below is not complete. When you fill the whole table and compute the maximum number of runners for each range, you can see that you need to put three bottles of water in Range 11, two in Range 22 and Range 33, and one in Range 44, Range 55, and Range 66. Note that at 480480s, Runner 22 leaves Range 22 and Runner 33 arrives at Range 22, both of which will be ignored as their distance from the starting point is an integer. At 480480s, no runner is in Range 11 and in Range 33 and Runner 11 is in Range 22. Then, for example, at 481481s, Runner 11 and Runner 33 will be in Range 22.

Time elapsedRange 11Range 22Range 33Range 44Range 55Range 66
(00s, 240240s)330000000000
(240240s, 350350s)221100000000
(350350s, 480480s)112200000000
(480480s, 710710s)002211000000
(710710s, 720720s)001122000000
…\dots…\dots…\dots…\dots…\dots…\dots…\dots

Given the number of runners, the length of the course, and the amount of time each runner will spend in each range, write a program to compute the number of bottles to be put in each range.

입력

Your program is to read from standard input. The input starts with a line containing two integers, nn and mm (1≤n≤1001 ≤ n ≤ 100, 1≤m≤3001 ≤ m ≤ 300), where nn is the number of runners and mm is the length of the course. In the following nn lines, the ii-th line contains mm positive integers that represent the amount of time Runner ii will spend in each range. More precisely, the jj-th number on the line is the time Runner ii will spend in Range jj. No runner will spend more than 10,00010\\,000 seconds in any range.

출력

Your program is to write to standard output. Print exactly one line. The line should contain the numbers of bottles in each range from Range 11 to Range mm.

예제3

  1. 예제 1

    입력
    3 6
    350 360 370 380 390 400
    240 240 240 240 240 240
    480 480 520 600 600 600
    
    예상 출력
    3 2 2 1 1 1
    
  2. 예제 2

    입력
    4 5
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    
    예상 출력
    4 4 4 4 4
    
  3. 예제 3

    입력
    3 5
    1 1 1 1 1
    5 5 5 5 5
    25 25 25 25 25
    
    예상 출력
    3 1 1 1 1