CSES - Movie Festival

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1629
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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.

Output

  • Print one integer: the maximum number of movies.

Constraints

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

Example Input

3
3 5
4 9
5 8

Example Output

2

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.