Logo
(追記) (追記ここまで)

28491번 - Swords 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB2131139151.705%

문제

Yan Hao has $n$ swords numbered from 1ドル$ to $n$. Sword $i$ has attack $a[i]$ and defence $b[i]$.

Yan Hao thinks that sword $i$ is useless if there exists a different sword $j$ ($j \ne i$) such that $a[i] ≤ a[j]$ and $b[i] ≤ b[j]$. That is, a sword $i$ is useless if the attack and defence of another sword $j$ are both at least as good as that of sword $i$. 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 1ドル$ integer, $n$.

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

출력

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

제한

  • 1ドル ≤ n ≤ 100,000円$
  • 1ドル ≤ a[i], b[i] ≤ 10^9$
  • For all 1ドル ≤ i < j ≤ n,ドル $a[i] \ne a[j]$ or $b[i] \ne b[j]$

서브태스크

번호배점제한
111

$n ≤ 500$

221

$a[i], b[i] ≤ 500$

334

$a[i] = i$

425

$a[i] \ne a[j]$ for every 1ドル ≤ i < j ≤ n$

59

No additional constraints

예제 입력 1

3
2 3
1 3
5 3

예제 출력 1

1

Comparing sword 1ドル$ with sword 3ドル,ドル we have $a[1] = 2 ≤ 5 = a[3]$ and $b[1] = 3 ≤ 3 = b[3],ドル so sword 1ドル$ is useless.

Comparing sword 2ドル$ with sword 1ドル,ドル we have $a[2] = 1 ≤ 2 = a[1]$ and $b[2] = 3 ≤ 3 = b[1],ドル so sword 2ドル$ is useless.

Sword 3ドル$ is the only useful sword.

예제 입력 2

4
5 6
2 5
6 9
1 3

예제 출력 2

1

힌트

출처

Olympiad > National Olympiad in Informatics (Singapore) > Qualification > NOI 2023 Qualification 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /