#P5338. Online Judge Ranking Query
Online Judge Ranking Query
Online Judge Ranking Query
In ACM contest style, contestants are ranked based on the number of solved problems and their penalty time. A contestant is considered to be ranked higher than another if:
- The number of solved problems is greater.
- If the number of solved problems is equal, then the contestant with the lower penalty time is ranked higher.
Whenever a contestant successfully solves a problem, the system should output how many contestants are currently ranked ahead of him. Note that contestants having exactly the same number of solved problems and penalty time are not considered to be ahead.
The ranking conditions can be formally represented as: $$ y.S > x.S \quad \text{or} \quad (y.S = x.S \text{ and } y.T < x.T) $$ where S is the number of solved problems and T is the penalty time.
inputFormat
The first line contains an integer n representing the number of submissions.
Each of the following n lines contains two integers S and T, where S denotes the number of solved problems and T denotes the penalty time.
outputFormat
For each submission, output a single integer in a new line which represents the number of contestants that are currently ranked ahead of the contestant who just solved the problem.
sample
3
1 10
2 5
1 10
0
0
1
</p>