#P6763. [BalticOI 2010] Printed Circuit Board (Day1)

[BalticOI 2010] Printed Circuit Board (Day1)

Description

You have infinitely many Cartesian coordinate systems. You are given NN line segments. Each segment connects (Xi,1,0)(X_{i,1}, 0) and (Xi,2,H)(X_{i,2}, H), where HH 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 NN, representing the number of segments.
The next NN lines each contain two integers Xi,1,Xi,2X_{i,1}, X_{i,2}, representing one segment.

Output Format

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

2
1 1
3 3
1
2
1 3
3 1
2

Hint

Constraints

For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 0Xi,1,Xi,21060 \le X_{i,1}, X_{i,2} \le 10^6. All Xi,1X_{i,1} are pairwise distinct, and all Xi,2X_{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

Translated by ChatGPT 5