PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000099. Sắp lịch học tối đa (Course Schedule III)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sắp lịch học tối đa (Course Schedule III)
Course Schedule III
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
You have courses. Course requires consecutive days and must finish by day . Starting on day 1, you can take only one course at a time, in any chosen order. You may skip courses. Find the maximum number of courses completed.
Input
Line 1 contains . Each of the following lines contains .
Output
Print the maximum number of completed courses.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
4
100 200
200 1300
1000 1250
2000 3200
Output
3
Explanation
Take courses , , to finish at days , , , each no later than its deadline. No fourth course can be added; the maximum is .