101833: [AtCoder]ABC183 D - Water Heater

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

We have a water heater, which supplies $W$ liters of hot water per minute.

There are $N$ people. The $i$-th person plans to use $P_i$ liters of hot water per minute boiled by the heater from Time $S_i$ to $T_i$ (excluding at Time $T_i$ exactly). As hot water gets cold fast, it cannot be stored.

Is it possible to supply hot water to the people according to their plans?

Constraints

  • $1\leq N \leq 2\times 10^5$
  • $0\leq S_i < T_i \leq 2\times 10^5$
  • $1\leq W, P_i \leq 10^9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $W$
$S_1$ $T_1$ $P_1$
$\vdots$
$S_N$ $T_N$ $P_N$

Output

If it is possible to supply hot water to the people according to their plans, print Yes; otherwise, print No.


Sample Input 1

4 10
1 3 5
2 4 4
3 10 6
2 4 1

Sample Output 1

No

Between Time $3$ and $4$, the $2$-nd, $3$-rd, and $4$-th persons plan to use $4$, $6$, and $1$ liter(s) of hot water per minute, for a total of $11$ liters per minute.

The water heater can only supply $10$ liters of hot water per minute, which is not enough.


Sample Input 2

4 10
1 3 5
2 4 4
3 10 6
2 3 1

Sample Output 2

Yes

Sample Input 3

6 1000000000
0 200000 999999999
2 20 1
20 200 1
200 2000 1
2000 20000 1
20000 200000 1

Sample Output 3

Yes

Input

题意翻译

### 题目描述 有 $1$ 个热水器,每分钟可以提供 $W$ 升热水。 现在来了 $N$ 个人想使用热水。第 $i$ 个人打算从时刻 $S_i$ 使用到时刻 $T_i$( $T_i$ 除外),每分钟需要使用 $P_i$ 升热水。由于热水倒出来会迅速变冷,因此不能储存。 你能按照他们的计划提供热水吗? ### 输入格式 输入按照以下格式使用标准输入: 第 $1$ 行:$N$ 和 $W$ ; 第 $2$ 到 $N+1$ 行:第 $i$ 行分别输入 $S_i$ , $T_i$ , $P_i$ 。 ``` N W S(1) T(1) P(1) ... S(N) T(N) P(N) ``` ### 输出格式 如果你可以按计划为每个人提供热水,请输出 `Yes` ,否则输出 `No` 。 ### 数据限制 - $1\le N\le 2\times 10^5$ - $0\le S_i < T_i \le 2\times 10^5$ - $1\le W,~P_i\le 10^9$ - 输入的都是整数 ### 样例 1 解释 在时刻 $3$ 与时刻 $4$ 之间,第 $2,~3,~4$ 个人每分钟分别需要使用 $4,~6,~1$ 升的热水,总共需要每分钟 $11$ 升热水的供应量;但是热水器每分钟只能供应 $10$ 升的热水,因此无法按计划供应热水。

加入题单

算法标签: