~/algor $ cat problems/ochkoz-zallar-soni
Minimum number of rooms
Medium
1000 ms
128 MB
47%
There are $n$ lessons in a day: the $i$-th starts at time $s_{i}$ and ends at time $e_{i}$. Only one lesson can take place in a room at a time; if a lesson ends at time $t$, another one may start in that room at time $t$. What is the smallest number of rooms needed to hold all the lessons?
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $s_{i}$ and $e_{i}$.
Output
One integer — the smallest number of rooms.
Note
$1 \le n \le 10^{5}$
$0 \le s_{i} \lt e_{i} \le 10^{9}$
Examples
Input #1
4 9 12 10 11 11 14 13 15
Output #1
2
Input #2
2 1 5 5 9
Output #2
1