#C3562. Find the Best Destination
Find the Best Destination
Find the Best Destination
You are given scores from n friends for m destinations in the form of an n x m
matrix. For each destination, compute the cumulative score by summing the scores given by all friends. Formally, for each destination \(j\) (where \(1 \leq j \leq m\)), the cumulative score is:
\[ S_j = \sum_{i=1}^{n} a_{ij} \]
Your task is to find and output the 1-indexed destination with the highest cumulative score. In case of ties (i.e. multiple destinations have the same maximum cumulative score), output the smallest index among them.
Input/Output: The input is read from standard input and the output should be printed to standard output.
inputFormat
The first line of input contains two integers n
and m
, where n
is the number of friends and m
is the number of destinations. This is followed by n
lines, each containing m
space-separated integers representing the scores given by a friend for each destination.
Example:
3 4 8 6 7 5 5 7 8 6 6 5 9 8
outputFormat
Output a single integer representing the 1-indexed destination with the highest cumulative score.
## sample3 4
8 6 7 5
5 7 8 6
6 5 9 8
3
</p>