#K13551. Tournament Ranking Calculation
Tournament Ranking Calculation
Tournament Ranking Calculation
You are given the results from a series of challenges in a tournament. There are n participants and m challenges. In each challenge, every participant earns a score. The overall ranking of participants is determined first by the sum of their scores across all challenges (higher total score earns a higher ranking) and, in the case of ties, by their score in the last challenge (higher score in the last challenge wins). The ranking should be presented as a list of integers, where the i-th integer represents the rank of the i-th participant (with rank 1 being the highest).
Note: If two participants have the same total score and the same last challenge score, their relative order does not matter (but in our input cases, such a tie does not occur).
Formula: The total score for participant i is given by \[ T_i = \sum_{j=1}^{m} s_{j,i}, \] where \(s_{j,i}\) is the score of the i-th participant in the j-th challenge.
inputFormat
The input is given via standard input (stdin) in the following format:
n m s11 s12 ... s1n s21 s22 ... s2n ... sm1 sm2 ... smn
Where:
- n is the number of participants.
- m is the number of challenges.
- Each of the next m lines contains n integers representing the scores of all participants for that particular challenge.
outputFormat
Print a single line to standard output (stdout) with n integers separated by spaces. The i-th integer represents the rank of the i-th participant as determined by the ranking rules.
## sample4 3
10 20 30 40
40 30 20 10
20 30 40 50
4 3 2 1