Problems
After visiting Keukenhof, one of the world's largest flower gardens, Lieke became very fond of flowers, so she has decided to collect some tulips growing next to the road in order to build a beautiful bouquet. However, when collecting the flowers, she has to respect some rules due to the strict tulip protection laws in the Netherlands.
There are
Lieke wonders what the maximum number of tulips she can pick is if she picks her flowers optimally. Help her build a beautiful bouquet by finding the answer to her question!
Input
The first line of input contains a single integer
The following
[constraints]
1 \leq N \leq 2 \cdot 10^5 0 \leq l_i, r_i \leq N (i = 0,1,\ldots, N-1 )
Output
Output a single integer, the maximum number of tulips Lieke can pick while respecting the protection law.
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 8 | |
| #2 | 16 | |
| #3 | 28 | |
| #4 | 18 | |
| #5 | 30 | No additional constraints |
Example #1
3
0 3
1 0
1 0
1
if Lieke picks tulip
Example #2
5
0 3
1 0
0 1
2 0
1 0
3
the maximum possible number of tulips Lieke can pick is
Example #3
7
0 0
0 0
1 0
1 0
2 0
3 0
2 0
4
Example #4
6
2 2
2 2
2 2
2 2
2 2
2 2
2
Example #5
7
0 2
2 0
1 1
2 2
0 0
0 1
0 1
3