PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000063. Liên hoan phim II (Movie Festival II)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Liên hoan phim II (Movie Festival II)
Movie Festival II
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
There are movies with intervals and viewers. Each viewer can watch one entire movie at a time, and may start another exactly when the previous ends. Each movie counts at most once. Maximize the total number of fully watched movies.
Input
The first line has . The next lines contain .
Output
Print the maximum number of movies.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
5 2
1 5
8 10
3 6
2 5
6 9
Output
4
Explanation
Two viewers can take and , respectively: movies. All cannot fit because three movies overlap between time and time .