PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000241. Máy nước nóng (Water Heater)
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 nước nóng (Water Heater)
Water Heater
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A heater can supply at most liters per minute, with no storage. Person needs liters per minute throughout , including but excluding . Determine whether the heater can meet all demands.
Input
The first line contains . Each of the next lines contains .
Output
Print Yes if possible, otherwise No.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; for every group/person.
- Subtask 3 (50 points): ; ; ; .
Example 1
Input
4 10
1 3 5
2 4 4
3 10 6
2 4 1
Output
No
Explanation
Demand on [3,4) is 11, exceeding 10.
Example 2
Input
4 10
1 3 5
2 4 4
3 10 6
2 3 1
Output
Yes
Explanation
Demand is 10 on [2,3) and [3,4), and smaller elsewhere.
Example 3
Input
6 1000000000
0 200000 999999999
2 20 1
20 200 1
200 2000 1
2000 20000 1
20000 200000 1
Output
Yes
Explanation
The baseline is 999999999 and the extra unit intervals do not overlap; the peak is 1000000000.