#P8342. Predicting Final Rankings in a Multi‐Round Contest
Predicting Final Rankings in a Multi‐Round Contest
Predicting Final Rankings in a Multi‐Round Contest
In this problem, each contestant participates in a contest that consists of 6 rounds. In each round, a contestant earns an integer score between $0$ and $500$, inclusive. The final score is the sum of the scores in all 6 rounds. After all rounds, contestants are ranked by their total scores in descending order. In case of ties (i.e. when two contestants have the same final score), the tie is broken by lexicographical order of their names (the contestant with the lexicographically smaller name is ranked higher). It is guaranteed that no two contestants have the same name.
Today is the final round of a public contest. Before the last round is played, each contestant (beekeeper) wants to know the best and worst ranking positions they can possibly achieve after round 6. In other words, assuming that in round 6 every contestant can score any integer between $0$ and $500$, determine for each contestant the minimum rank they can obtain (if they get $500$ and all other contestants get $0$, with tie-breaking in their favor) and the maximum rank they can obtain (if they get $0$ and all other contestants get $500$, with tie‐breaking working against them).
The input provides the number of contestants and for each contestant their name and the scores obtained in the first 5 rounds. For each contestant, you should output two numbers on a separate line: the best (smallest) possible ranking and the worst (largest) possible ranking.
Note on tie-breaking: When a contestant's potential total score is equal to another's potential total score, the contestant whose name is lexicographically smaller is considered to have the higher rank.
inputFormat
The first line of input contains a single integer n ($1 \le n \le 10^5$), representing the number of contestants.
Each of the following n lines contains a contestant's information in the following format:
name score1 score2 score3 score4 score5
Here, name
is a string (unique among contestants) and score1, score2, score3, score4, score5
are integers representing the scores obtained in the first 5 rounds (each between $0$ and $500$).
outputFormat
Output n lines. The i-th line should contain two integers separated by a space: the best possible ranking and the worst possible ranking for the i-th contestant (in the same order as input).
sample
3
alice 250 250 250 250 250
bob 300 300 300 300 300
claire 200 200 200 200 200
1 3
1 2
2 3
</p>