아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Swords

면접 대비

시간 제한1초메모리 제한1024 MB

요약
모든 공격력과 방어력 쌍이 서로 다를 때, 다른 검에게 두 능력치 모두에게 지지 않는 검의 개수를 센다.
난이도

보통10점 중 5점

유형
배열, 정렬, 투 포인터
정답자
아직 제출이 없습니다

문제

Yan Hao has nn swords numbered from 11 to nn. Sword ii has attack a\[i]a\[i] and defence b\[i]b\[i].

Yan Hao thinks that sword ii is useless if there exists a different sword jj (j≠ij \ne i) such that a\[i]≤a\[j]a\[i] ≤ a\[j] and b\[i]≤b\[j]b\[i] ≤ b\[j]. That is, a sword ii is useless if the attack and defence of another sword jj are both at least as good as that of sword ii. If a sword is not useless, we say that it is useful.

Two swords are considered equivalent if they have the same attack and same defence. It is guaranteed that no pair of swords are equivalent.

Help Yan Hao find the number of useful swords in his collection.

입력

The first line of input contains exactly 11 integer, nn.

The next nn lines of input contains two space-separated integers each. The ii-th such line of input will contain a\[i]a\[i] and b\[i]b\[i] respectively, indicating the attack and defence of sword ii.

출력

The output should contain one integer, the number of useful swords.

제한

  • 1≤n≤100,0001 ≤ n ≤ 100\\,000
  • 1≤a\[i],b\[i]≤1091 ≤ a\[i], b\[i] ≤ 10^9
  • For all 1≤i<j≤n1 ≤ i < j ≤ n, a\[i]≠a\[j]a\[i] \ne a\[j] or b\[i]≠b\[j]b\[i] \ne b\[j]

예제2

  1. 예제 1

    입력
    3
    2 3
    1 3
    5 3
    
    예상 출력
    1
    
  2. 예제 2

    입력
    4
    5 6
    2 5
    6 9
    1 3
    
    예상 출력
    1