#C1812. Archery Matches
Archery Matches
Archery Matches
In this problem, you are given ( n ) squads, each with a list of archers' skill ratings. Your task is twofold:
-
Compute the result of all pairwise inter-squad matches. In a match between Squad ( i ) and Squad ( j ), the squad with the higher total skill rating (i.e. ( \sum_{k} rating_{k} )) wins. In case of a tie, the squad with the smaller index wins.
-
For each squad, compute its maximum possible skill rating by selecting an optimal subset of archers. Since all ratings are non-negative, the optimal subset is the entire squad, and its maximum skill rating is simply the sum of its archers' skill ratings: ( \text{Max Skill Rating} = \sum_{k} rating_{k} ).
Your program should read the input from standard input and output the results to standard output. The output should first list the match results (if there are at least two squads) and then the maximum skill ratings for each squad.
inputFormat
The first line of input contains an integer ( n ) representing the number of squads. The following ( n ) lines each contain zero or more integers separated by spaces representing the skill ratings of the archers in that squad. An empty line indicates that the squad has no archers.
outputFormat
Print the results of each inter-squad match, one per line, in the format:
Squad i vs Squad j: Winner is Squad X
for every pair of squads (( i < j )). Then, for each squad, print a line in the format:
Max skill rating of Squad i: S
where ( S ) is the sum of the skill ratings of the squad. All output should be printed to standard output.## sample
3
10 20 30 10
5 15 10
25 30
Squad 1 vs Squad 2: Winner is Squad 1
Squad 1 vs Squad 3: Winner is Squad 1
Squad 2 vs Squad 3: Winner is Squad 3
Max skill rating of Squad 1: 70
Max skill rating of Squad 2: 30
Max skill rating of Squad 3: 55
</p>