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

Bài tập thuộc lộ trình

1 lộ trình

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 WW liters per minute, with no storage. Person ii needs PiP_i liters per minute throughout [Si,Ti)[S_i,T_i), including SiS_i but excluding TiT_i. Determine whether the heater can meet all demands.

Input

The first line contains N,WN,W. Each of the next NN lines contains Si,Ti,PiS_i,T_i,P_i.

Output

Print Yes if possible, otherwise No.

Subtasks

  • Subtask 1 (20 points): 1≤N≤501\le N\le 50; 1≤W≤10000000001\le W\le 1000000000; 0≤Si<Ti≤500\le S_i<T_i\le 50; 1≤Pi≤10000000001\le P_i\le 1000000000.
  • Subtask 2 (30 points): 1≤N≤2000001\le N\le 200000; 1≤W≤10000000001\le W\le 1000000000; 0≤Si<Ti≤2000000\le S_i<T_i\le 200000; 1≤Pi≤10000000001\le P_i\le 1000000000; Si=0S_i=0 for every group/person.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤W≤10000000001\le W\le 1000000000; 0≤Si<Ti≤2000000\le S_i<T_i\le 200000; 1≤Pi≤10000000001\le P_i\le 1000000000.

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.