RATING - Coder Ratings


Some of the more elite (and not-so-elite) coders around take part in a certain unnamed programming contest. In said contest, there are multiple types of competitions. Here, we consider the Open and High School competition types. For each type, each competitor receives a rating, an integer between 1 and 100000, inclusive. A coder's rating is based upon his or her level of performance in matches and is calculated using a complicated formula which, thankfully, you will not be asked to implement.

Although the Open and High School ratings for a coder who has participated in both competition types lately are usually close, this is not always the case. In particular, High School matches are more about speed, since many coders are able to solve all the problems, whereas Open matches require more thinking and there is a steeper curve in terms of problem difficulty.

Problem Statement
You are given N coders (1 ≤ N ≤ 300000), conveniently numbered from 1 to N. Each of these coders participates in both High School and Open matches. For each coder, you are also given an Open rating Ai and a High School rating Hi. Coder i is said to be better than coder j if and only if both of coder i's ratings are greater than or equal to coder j's corresponding ratings, with at least one being greater. For each coder i, determine how many coders coder i is better than.

Input Format
On the first line of input is a single integer N, as described above.
N lines then follow. Line i+1 contains two space-separated integers, Ai and Hi.

Output Format
Line i should contain the number of coders that coder i is better than.

Sample Input

8
1798 1832
862 700
1075 1089
1568 1557
2575 1984
1033 950
1656 1649
1014 1473

 

Sample Output

6
0
2
4
7
1
5
1

 


hide comments
akt_1998: 2017-06-24 23:32:12

Easy :)
but take care of this statement "or equal to coder j's corresponding ratings, with at least one being greater"

SUBHAM SANGHAI: 2017-06-22 21:01:24

Sorting+BIT ..
Note: 2
1 2
1 2
output=>
0
0
but
2
5 4
5 5
output=>
0
1

Last edit: 2017-06-22 21:02:29
spk: 2016-08-17 18:06:46

BIT+hashing, AC in 0.33

mohab3333: 2016-08-09 01:33:23

if You'r using BST make the max value 300000 ;)

youssefelsa3ed: 2016-08-09 01:31:37

Easy one.
Got AC from 5th time :'D

Tiago NĂ¡poli: 2016-07-14 17:32:26

Case:
6
4 1
5 1
5 2
5 3
5 3
6 1
ans:
0
1
2
3
3
2

vijaynag: 2016-06-22 07:10:58

Is there a way to get the failed test case ? I'm getting wrong answer and I must have missed some corner case.

romilpunetha: 2016-06-12 23:49:28

For those getting WA at around 9, check
2
5 5
5 4
ans:
1
0

karan: 2015-12-25 10:03:34

For those getting WA on 9th test case :
Consider this test case :
3
5 5
5 5
6 7

qduynl: 2015-10-18 07:35:22

https://traitaodo.wordpress.com/2015/10/18/coder-rating-crate/


Added by:Brian Bi
Date:2009-04-10
Time limit:0.176s-1.846s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET
Resource:own problem