#P6260. Miniature Golf Rankings

    ID: 19479 Type: Default 1000ms 256MiB

Miniature Golf Rankings

Miniature Golf Rankings

A group of friends have just finished playing a round of miniature golf. A miniature golf course consists of m holes. In each hole, every player takes turns hitting the ball repeatedly until it drops into the hole. The score for a hole is the number of strokes taken. However, to prevent slow play, a cap is applied: if a player takes more than l strokes on a hole, the score is recorded as l and the turn ends. The cap l is a positive integer. After the game (played without any cap) the players will adjust their scores by replacing any hole score greater than \(l\) with \(l\).

The adjusted total score for a player given a cap \(l\) is defined as follows:

\(S_i(l)=\sum_{j=1}^{m} \min(a_{i,j},\; l)\)

For this problem, the rank of a player is defined as the number of players whose adjusted total score is less than or equal to that player's adjusted total score. In other words, for a fixed \(l\), if the adjusted scores are \(S_1,S_2,\dots,S_n\), then the rank of player i is:

\(\text{rank}_i(l)=|\{ j \mid S_j(l)\le S_i(l)\}|\)

The twist is, the friends have not yet looked up the value of \(l\) and they are curious to know the best (i.e. smallest) rank each player could possibly achieve if an optimal cap \(l\) is chosen. Given the raw scores \(a_{i,j}\) for each player and each hole, determine for each player the minimum rank that can be achieved over all possible positive integers \(l\).

inputFormat

The first line contains two integers n and m (\(1 \le n, m \le 100\)), representing the number of players and the number of holes, respectively.

Each of the next n lines contains m positive integers. The j-th number on the i-th line denotes \(a_{i,j}\), the number of strokes taken by the i-th player on the j-th hole. All stroke counts are positive integers and are reasonably bounded.

outputFormat

Output a single line containing n integers separated by spaces. The i-th integer should be the minimum rank that the i-th player can achieve after applying the cap adjustment with some positive integer \(l\).

sample

3 2
2 7
4 4
3 5
1 3 2