#P11853. Max Tree Watering
Max Tree Watering
Max Tree Watering
Tree Planting Day is approaching and the school has organized volunteers to water tree saplings arranged in a row with indices \(0, 1, 2, \dots\).
There are \(n\) volunteers. The \(i\)-th volunteer picks an interval \(\left[a_{i}, b_{i}\right]\) which means that he waters every tree with an index between \(a_{i}\) and \(b_{i}\) (inclusive). For example, if a volunteer picks the interval \(\left[4, 9\right]\), then he waters the trees with indices 4, 5, 6, 7, 8, and 9 once each.
After all volunteers have watered their chosen intervals, some trees might have been watered multiple times while others might not have been watered at all. Your task is to determine the maximum number of times any tree has been watered.
inputFormat
The first line contains a single integer \(n\) indicating the number of volunteers.
Each of the following \(n\) lines contains two integers \(a_i\) and \(b_i\) (with \(a_i \leq b_i\)) representing the watering interval for the \(i\)-th volunteer.
outputFormat
Output a single integer, the maximum number of times any tree has been watered.
sample
3
4 9
0 5
2 7
3