We know that the playground has a special place among the people of Barre. Shirfarhad…
- User
We know that the playground has a special place among the people of Barre.
Shirfarhad and Kayanush had gone to the heart of nature when they decided to play baze! In this game n There are n intervals and the winner is the one who finds the size of the largest optimal set. A set of intervals is arbitrary if and only if all its members are distinct and for any two intervals such a a and b b, or a a inside b b is placed or vice versa.
You, as a fan of Shirfarhad, find the size of the largest collection of Barrepasand so that he wins. Note that the size of a set is equal to the number of its members.
input In the first line n n has come. in each of n n next line a i a i , the beginning of the interval i and b i b i end of period i i is given 1 ≤ n ≤ 100
000 1≤n≤100 000 1 ≤ a i ≤ b i ≤ 1
000
000 1≤a i ≤b i ≤1 000 000 a i , b i ∈ N a i ,b i ∈N
output Print the size of the largest array of parameters on a single output line.
Example Sample entry 1 3 3 4 2 5 1 6 Plain text Sample output 1 3 Plain text Sample input 2 5 10 30 20 40 30 50 10 60 30 40 Plain text Sample output 2 3 Plain text Explanation of example 2: In this example, the size of the largest suitable set is equal to 3, and intervals 3, 4, and 5 (in order of input) make this set.
Sample entry 3 6 1 4 1 5 1 6 1 7 2 5 3 5 Plain text Sample output 3 5 Plain text Explanation of example 3: In this example, it is enough to remove the first interval (in order of input) from the set, as a result, the other 5 intervals form the largest optimal set. c++
- Assistant