#K45817. Game Winner Determination
Game Winner Determination
Game Winner Determination
You are given a game with \( n \) players and \( m \) rounds. Each player scores a certain number of points in every round. The overall score for a player is the sum of points scored in all rounds:
\( T_i = \sum_{j=1}^{m} s_{ij} \)
Additionally, the best performance in a single round for a player is defined as:
\( M_i = \max_{1 \le j \le m} \{ s_{ij} \} \)
The winner is determined by the following rules:
- The player with the highest total score \( T_i \) wins.
- If there is a tie in total score, then the player with the highest single round score \( M_i \) wins.
- If there is still a tie, the player with the smallest index (0-indexed) wins.
Your task is to determine the index of the winning player.
inputFormat
The first line of input contains two integers \( n \) and \( m \) separated by a space, where \( n \) is the number of players and \( m \) is the number of rounds.
The following \( n \) lines each contain \( m \) integers separated by spaces, representing the scores of a player in each round.
outputFormat
Output a single integer representing the 0-indexed index of the winning player.
## sample3 3
10 20 30
20 30 10
30 10 20
0