#C7377. Treasure Hunt Points
Treasure Hunt Points
Treasure Hunt Points
In the Treasure Hunt competition, there are \( n \) teams and \( m \) challenges. In every challenge, each team submits a treasure with a certain value. The team that submits the treasure with the highest value for that challenge earns points equal to the value of the treasure. If there is a tie, the team with the lower index (i.e. the first encountered in the input order) wins the challenge and earns the points.
Your task is to compute the total points earned by each team after all challenges.
Note: The input is given through standard input (stdin) and the output must be printed to standard output (stdout). The scoring rule for each challenge is as follows:
For each challenge \( j \) (where \( 1 \leq j \leq m \)), determine the team \( i \) (where \( 1 \leq i \leq n \)) that has the maximum value \( A_{ij} \). Then, add \( A_{ij} \) to the total score of team \( i \).
inputFormat
The first line of input contains two space-separated integers \( n \) and \( m \) representing the number of teams and the number of challenges, respectively.
This is followed by \( n \) lines, each containing \( m \) space-separated integers. The \( j \)-th integer in the \( i \)-th line represents the treasure value \( A_{ij} \) submitted by team \( i \) in challenge \( j \).
Input example:
4 3 100 200 300 150 200 250 300 150 100 200 300 250
outputFormat
Output a single line with \( n \) space-separated integers, where the \( i \)-th integer represents the total points earned by team \( i \) after all challenges.
Output example:
300 0 300 300## sample
4 3
100 200 300
150 200 250
300 150 100
200 300 250
300 0 300 300