#C6378. Minimizing Score Difference
Minimizing Score Difference
Minimizing Score Difference
You are given M participants competing over N rounds. In each round, every participant earns a score. The total score for each participant is the sum of the scores achieved in all rounds. Your task is to compute the minimum possible difference between the highest and lowest total scores among all participants.
The formula to calculate the difference is given by:
$$\text{Difference} = \max_{1 \leq i \leq M}\,S_i - \min_{1 \leq i \leq M}\,S_i$$
where \(S_i\) is the total score of the \(i\)-th participant.
Read the input from standard input and print the result to standard output.
inputFormat
The input consists of multiple lines. The first line contains two integers M and N, where M is the number of participants and N is the number of rounds. The following M lines each contain N space-separated integers representing the scores of a participant in each round.
Example:
3 4 10 20 30 40 15 25 35 45 5 15 25 35
outputFormat
Output a single integer, which is the difference between the highest and lowest total scores among all participants.
## sample3 4
10 20 30 40
15 25 35 45
5 15 25 35
40