#P10728. [NOISG 2023 Qualification] Swords

    ID: 11725 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学贪心2023排序NOISG(新加坡)

[NOISG 2023 Qualification] Swords

Problem Description

YH has nn swords. The ii-th sword has attack power aia_i and defense ability bib_i.

For a sword ii, if there exists a j(ji)j(j \not = i) such that aiaja_i \le a_j and bibjb_i \le b_j, then YH considers this sword useless. Otherwise, he considers it useful.

In this problem, it is guaranteed that it is impossible to find two swords i,ji, j such that ai=aja_i = a_j and bi=bjb_i = b_j.

Please help YH find the number of useful swords among these nn swords.

Input Format

The first line contains an integer nn.

The next nn lines each contain two integers ai,bia_i, b_i, representing the attack power and defense ability of the ii-th sword.

Output Format

Print one integer, the number of useful swords.

3
2 3
1 3
5 3

1
4
5 6
2 5
6 9
1 3

1

Hint

Subtask\text{Subtask} Score Special Property
11 1111 n500n \le 500
22 2121 ai,bi500a_i, b_i \le 500
33 3434 ai=ia_i = i
44 2525 For every 1i<jn1 \le i < j \le n, aiaja_i \not = a_j
55 99 None

For all testdata, 1n1000001 \le n \le 100000, 1ai,bi1091 \le a_i, b_i \le 10^9.

Translated by ChatGPT 5