PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000022. Lịch công việc đúng hạn (Megalomania)
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ịch công việc đúng hạn (Megalomania)
Megalomania
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are jobs. Job needs units of processing time and must finish no later than deadline . Only one job can be processed at a time and jobs cannot be interrupted. Determine whether all jobs can meet their deadlines.
Input
The first line contains . Each of the next lines contains .
Output
Print Yes if a feasible schedule exists, otherwise print No.
Constraints
- .
- for .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.