#C7363. Team Ranking
Team Ranking
Team Ranking
In this problem, teams submit scores for various challenge attempts. For each team, you will receive several scores and must rank the teams based on their best individual score. In case of a tie (i.e. when multiple teams have the same best score), the team with the lower total sum of scores is ranked higher. If a tie still remains, the team with the smaller team number wins.
Formally, for each team (i), let (B_i = \max(\text{scores})) and (S_i = \sum(\text{scores})). The teams are ranked so that team (i) is ranked higher than team (j) if either:
(1.\ B_i > B_j),
(2.\ B_i = B_j) and (S_i < S_j), or
(3.\ B_i = B_j,\ S_i = S_j) and (i < j).
Your task is to output the final ranking as a series of lines, each containing the rank and the team number.
inputFormat
The input is given via standard input. The first line contains an integer (N), representing the number of submissions. Each of the following (N) lines contains two values: a team number (an integer) and a score (a floating-point number) separated by a space.
outputFormat
For each team that appears in the input, output a line with two integers: the rank of the team followed by the team number, separated by a space. The ranking should start at 1 and the teams must be listed in order of increasing rank.## sample
11
1 90.5
1 85.3
2 88.0
2 90.5
2 65.1
3 70.0
3 75.0
4 85.0
4 90.5
4 85.5
4 92.0
1 4
2 1
3 2
4 3
</p>