P11853 [CSP-J 2022 Shandong] Arbor Day

Background

Due to the pandemic, Shandong Province canceled the CSP-J 2022 certification event and set a new problem in March of the following year, holding a make-up contest within the province.

Description

Arbor Day is coming soon, and the school is going to organize volunteers to water young trees. There is a row of young trees, numbered $0,1,2,\dots$ in order. Now there are $n$ volunteers to water the trees. The $i$-th volunteer chooses an interval $\left[a_{i},b_{i}\right]$, meaning that the $i$-th volunteer will water every tree in the interval $\left[a_{i},b_{i}\right]$ once. For example, if a volunteer chooses the watering interval $\left[4,9\right]$, it means they will water each tree numbered $4,5,6,7,8,9$ once. After all volunteers finish watering their chosen intervals, some trees may have been watered multiple times by different volunteers, and some trees may not have been watered at all. Please find the maximum number of times any single tree has been watered.

Input Format

Line $1$ contains one integer $n$, the number of volunteers. Lines $2$ to $n+1$ each contain two integers $a_{i},b_{i}$ ($i=0,1,2,\dots n-1$), representing the interval chosen by volunteer $i$.

Output Format

Output $1$ line containing $1$ integer, the number of times the most-watered tree has been watered.

Explanation/Hint

### Constraints * For all testdata: $n \le 10^{5}$; $0\le a_{i}\le b_{i}\le 10^{6}$。 ::cute-table{tuack} |Test Point ID|$a_{i}\le$|$b_{i}\le$|$n\le$|Special Property| |:-:|:-:|:-:|:-:|:-:| |$1,2,3$|$10^{3}$|$10^{3}$|$10^{3}$|None| |$4,5,6,7$|$10^{6}$|$10^{6}$|$10^{5}$|None| |$8$|$10^{6}$|$10^{6}$|$10^{5}$|$a_{i}=b_{i}$| |$9$|$10^{6}$|$10^{6}$|$10^{5}$|$a_{i}=1,b_{i}=10^{3}$| |$10$|$10^{6}$|$10^{6}$|$10^{5}$|None| Translated by ChatGPT 5