#C3347. Taco Championship
Taco Championship
Taco Championship
You are given the score results of a taco championship. There are M participants and each participates in N challenges. In the jth challenge, the ith participant earns a score sij.
For each participant i, define the total score as
( S_i = \sum_{j=1}^{N} s_{ij} )
and let \( T_i \) be the list of scores sorted in non-increasing order. The winner is determined by comparing the tuple \( (S_i, T_i) \) in lexicographical order; that is, a participant \( i \) is considered better than participant \( k \) if either:
- \( S_i > S_k \), or
- \( S_i = S_k \) and \( T_i \) is lexicographically greater than \( T_k \) (i.e. the highest score is compared first, then the second highest, etc.).
If there is still a complete tie, choose the participant with the smallest index (0-indexed). Your task is to determine the index of the winning participant.
inputFormat
The input is read from stdin and has the following format:
- The first line contains two integers
M
andN
separated by a space, whereM
is the number of participants andN
is the number of challenges. - The next
M
lines each containN
integers. The ith of these lines represents the scores of the ith participant.
outputFormat
The output should be written to stdout and consists of a single integer: the index (0-indexed) of the winning participant.
## sample1 3
70 80 90
0