PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000097. Làm hài lòng nhiều khách hàng nhất (Keep the Customer Satisfied)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Làm hài lòng nhiều khách hàng nhất (Keep the Customer Satisfied)
Keep the Customer Satisfied
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given orders, order needs consecutive units of processing and must finish by deadline . Only one order can be processed at a time, starting at time zero. You may discard orders. Maximize the number completed on time.
Input
Line 1 contains . The following lines each contain .
Output
Print one integer, the maximum number of orders finished by their deadlines.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
4
4 4
3 5
2 7
3 8
Output
3
Explanation
Complete jobs , , consecutively at times . Three are possible; all four require units of work but the latest deadline is .