P28116 [洛谷] [NOISG 2023 Qualification] Swords
普及
题目描述

Problem Description

YH has $n$ swords, where the attack power of the $i$-th sword is $a_i$ and its defense capability is $b_i$.

For a sword $i$, if there exists a $j (j \neq i)$ such that $a_i \leq a_j$ and $b_i \leq b_j$, then YH considers this sword useless. Otherwise, he considers it useful.

In this problem, we guarantee that it is impossible to find two swords $i$ and $j$ such that $a_i = a_j$ and $b_i = b_j$.

Please help YH determine the number of useful swords among these $n$ swords.

Input Format

The first line contains an integer $n$.

The next $n$ lines each contain two integers $a_i$ and $b_i$, representing the attack power and defense capability of the $i$-th sword, respectively.

Output Format

An integer representing the number of useful swords.

Sample Input and Output

Sample Input #1

3
2 3
1 3
5 3

Sample Output #1

1

Sample Input #2

4
5 6
2 5
6 9
1 3

Sample Output #2

1

Notes/Hints

Subtask Score Special Conditions
1 11 $n \leq 500$
2 21 $a_i, b_i \leq 500$
3 34 $a_i = i$
4 25 For every $1 \leq i < j \leq n$, $a_i \neq a_j$
5 9 None

For all data, $1 \leq n \leq 100000, 1 \leq a_i, b_i \leq 10^9$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 3 1 3 5 3
样例输出
1