PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000067. Hộp ghi hình (Entertainment Box)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hộp ghi hình (Entertainment Box)
Entertainment Box
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A recording device has independent recording slots and TV shows, each running from time to . One slot records one show at a time and may begin another exactly when the previous one ends. Count only completely recorded shows, each at most once. Find the maximum number of shows.
Input
The first line contains . Each of the next lines contains .
Output
Print the maximum number of fully recordable shows.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
3 1
1 2
2 3
2 3
Output
2
Explanation
There is one recording slot. Record and then one of the shows; the slot becomes free exactly at time . The other show overlaps, so the answer is .