PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000069. Máy in trên băng chuyền (Printing Machine)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Máy in trên băng chuyền (Printing Machine)
Printing Machine
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A conveyor brings products past a printer. Product is within the print range during the inclusive time interval . Printing is instantaneous but the printer requires at least one microsecond between consecutive prints. Each product can be printed at most once. Maximize the number of printed products.
Input
The first line contains . Each of the next lines contains in microseconds.
Output
Print the maximum number of products that can be printed.
Subtasks
- Subtask 1 (20 points): ; for every ; consecutive prints must be at least one microsecond apart.
- Subtask 2 (30 points): ; for every ; consecutive prints must be at least one microsecond apart.
- Subtask 3 (50 points): ; for every ; consecutive prints must be at least one microsecond apart.
Examples
Input
5
1 1
1 1
2 1
1 2
1 4
Output
4
Explanation
Print products at times . Each is in range at its printing time, and successive printings are at least one time unit apart. Five products cannot all be printed under the time windows, so the optimum is .