407992: GYM102961 F Movie Festival

Memory Limit:256 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Movie Festivaltime limit per test2.0 smemory limit per test256 megabytesinputstandard inputoutputstandard output

In a movie festival $$$n$$$ movies will be shown. You know the starting and ending time of each movie. What is the maximum number of movies you can watch entirely?

Input

The first input line has an integer $$$n$$$: the number of movies.

After this, there are $$$n$$$ lines that describe the movies. Each line has two integers $$$a$$$ and $$$b$$$: the starting and ending times of a movie.

Constraints:

  • $$$1 \le n \le 2 \cdot 10^5$$$
  • $$$1 \le a < b \le 10^9$$$
Output

Print one integer: the maximum number of movies.

ExampleInput
3
3 5
4 9
5 8
Output
2

加入题单

算法标签: