P6763 [BalticOI 2010] Printed Circuit Board (Day1)

Description

You have infinitely many Cartesian coordinate systems. You are given $N$ line segments. Each segment connects $(X_{i,1}, 0)$ and $(X_{i,2}, H)$, where $H$ is a positive number (but it is not given, and it is not needed to solve the problem). You need to place these segments into the Cartesian coordinate systems so that no two segments intersect. Find the minimum number of Cartesian coordinate systems needed to accommodate all these segments.

Input Format

The first line contains an integer $N$, representing the number of segments. The next $N$ lines each contain two integers $X_{i,1}, X_{i,2}$, representing one segment.

Output Format

Output one integer on a single line, representing the answer.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, $1 \le N \le 10^5$, $0 \le X_{i,1}, X_{i,2} \le 10^6$. All $X_{i,1}$ are pairwise distinct, and all $X_{i,2}$ are pairwise distinct. That is, no two endpoints are at the same position. #### Notes Translated from [BalticOI 2010 Day1 C Printed Circuit Board](https://boi.cses.fi/files/boi2010_day1.pdf)。 Translated by ChatGPT 5