Third Round Standings
Time limit1sMemory limit32 MB
Given two rounds of scores from 0 to 650, the task asks each contestant's highest and lowest final rank over third-round scores that respect dominance.
- Level
Medium7 of 10
- Topics
- Prefix sum, Greedy
- Solved
- No attempts yet
Problem
The third round of the contest is about to start. To predict the scores, assume the following.
- If contestant A scored strictly more points than contestant B in each of the first two rounds, then in the third round A scores at least as many points as B.
In every round, including the third one, a contestant can score any integer number of points from 0 to 650. The final standings list contestants from the largest sum of the points of all three rounds to the smallest. Contestants with an equal sum get the same place, and the next contestant gets the place that counts everyone ahead. For example, contestants with sums 1000, 1000, 900, 900 and 800 get places 1, 1, 3, 3 and 5.
You know the first round score and the second round score of all contestants. Under the assumption above, find the highest and the lowest place each contestant can get in the final standings after all three rounds.
Input
The first line contains the number of contestants ().
Each of the next lines contains the first round score and the second round score of one contestant. Both scores are integers from 0 to 650.
Output
For each contestant, in the order given in the input, print two integers on one line: the highest and the lowest place that contestant can get.