Under construction

Still being built. Things may change

Bottles

Interview

Time limit1sMemory limit2048 MB

Summary
Given each runner's time in every range, find for each range the maximum number of runners in it at the same moment.
Level

Medium4 of 10

Topics
Sorting, Prefix sum, Simulation
Solved
No attempts yet

Statement

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 \le i \le 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.

The weather is hot, so the organizers want to supply enough water. They keep a certain number of water bottles in each range. When a runner takes one bottle, they put another one down immediately. The organizers found that the optimal number of bottles in a range equals the maximum number of runners in that range at any moment during the race. Based on each runner's previous records, they estimated how many seconds he or she will spend in each range.

Input

The first line contains two integers nn and mm (1≤n≤1001 \le n \le 100, 1≤m≤3001 \le m \le 300), where nn is the number of runners and mm is the length of the course. The following nn lines each contain mm positive integers. The jj-th number on the ii-th line is the time Runner ii spends in Range jj. No runner spends more than 10 00010\,000 seconds in any range.

Output

Print exactly one line. The line contains the number of water bottles for each range, from Range 1 to Range mm.

Examples3

  1. Example 1

    Input
    3 6
    350 360 370 380 390 400
    240 240 240 240 240 240
    480 480 520 600 600 600
    
    Expected output
    3 2 2 1 1 1
    
  2. Example 2

    Input
    4 5
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    
    Expected output
    4 4 4 4 4
    
  3. Example 3

    Input
    3 5
    1 1 1 1 1
    5 5 5 5 5
    25 25 25 25 25
    
    Expected output
    3 1 1 1 1