#P11853. [CSP-J 2022 山东] 植树节

[CSP-J 2022 山东] 植树节

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.

Problem 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,0,1,2,\dots in order.

Now there are nn volunteers to water the trees. The ii-th volunteer chooses an interval [ai,bi]\left[a_{i},b_{i}\right], meaning that the ii-th volunteer will water every tree in the interval [ai,bi]\left[a_{i},b_{i}\right] once.

For example, if a volunteer chooses the watering interval [4,9]\left[4,9\right], it means they will water each tree numbered 4,5,6,7,8,94,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 11 contains one integer nn, the number of volunteers.

Lines 22 to n+1n+1 each contain two integers ai,bia_{i},b_{i} (i=0,1,2,n1i=0,1,2,\dots n-1), representing the interval chosen by volunteer ii.

Output Format

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

4
0 2
2 4
1 4
6 7
3
4
1000000 1000000
1000000 1000000
0 1000000
1 1000000
4

Hint

Constraints

  • For all testdata: n105n \le 10^{5}; 0aibi1060\le a_{i}\le b_{i}\le 10^{6}

::cute-table{tuack}

Test Point ID aia_{i}\le bib_{i}\le nn\le Special Property
1,2,31,2,3 10310^{3} None
4,5,6,74,5,6,7 10610^{6} 10510^{5}
88 ai=bia_{i}=b_{i}
99 ai=1,bi=103a_{i}=1,b_{i}=10^{3}
1010 None

Translated by ChatGPT 5