Segment - MarisaOJ: Marisa Online Judge

Segment

Time limit: 1000 ms
Memory limit: 256 MB
Given $n$ line segments on the number line. Choose the maximum number of line segments such that no two line segments share a common point. ### Input - The first line contains two integers $n$. - The next $n$ lines each contain two integers $l, r$, representing a line segment extending from point $l$ to $r$ on the number line. ### Output - Print an integer, the maximum number of line segments that can be chosen. ### Constraints - $1 \le n \le 10^5$. - $1 \le l \le r \le 10^9$. ### Example Input: ``` 5 6 8 2 3 5 6 2 5 2 5 ``` Output: ``` 2 ```