P9556 [SDCPC 2023] Orders
题目描述
某工厂在第 $1$ 天开工之前收到了 $n$ 笔订单,第 $i$ 笔订单可以用两个整数 $a_i$ 和 $b_i$ 描述,表示工厂需要在第 $a_i$ 天结束时交付 $b_i$ 件货物。
已知工厂每天能生产 $k$ 件货物,且第 $1$ 天开工之前没有任何存货,问该工厂能否完成所有订单。
输入格式
有多组测试数据。第一行输入一个整数 $T$($1 \le T \le 100$)表示测试数据组数,对于每组测试数据:
第一行输入两个整数 $n$ 和 $k$($1 \le n \le 100$,$1 \le k \le 10^9$)表示订单数量以及工厂每日能生产的货物数量。
对于接下来 $n$ 行,第 $i$ 行输入两个整数 $a_i$ 和 $b_i$($1 \le a_i, b_i \le 10^9$)表示第 $i$ 笔订单要求在第 $a_i$ 天结束时交付 $b_i$ 件货物。
输出格式
每组数据输出一行。若工厂能完成所有订单输出 $\texttt{Yes}$,否则输出 $\texttt{No}$。
**【样例解释】**
对于第一组样例数据,工厂每天能生产 $5$ 件货物。
- 在第 $1$ 天结束时,工厂共有 $5$ 件货物,可以完成第 $2$ 笔订单。交付后,工厂剩余 $2$ 件货物。
- 在第 $6$ 天结束时,工厂又多生产了 $25$ 件货物,共有 $27$ 件货物,可以完成第 $1$ 和第 $3$ 笔订单。交付后,工厂剩余 $0$ 件货物。
- 在第 $8$ 天结束时,工厂又多生产了 $10$ 件货物,共有 $10$ 件货物,可以完成第 $4$ 笔订单。交付后,工厂剩余 $9$ 件货物。
对于第二组样例数据,工厂每天能生产 $100$ 件货物。
- 在第 $3$ 天结束时,工厂共有 $300$ 件货物,可以完成第 $1$ 笔订单。交付后,工厂剩余 $100$ 件货物。
- 在第 $4$ 天结束时,工厂又多生产了 $100$ 件货物,共有 $200$ 件货物,无法完成第 $2$ 笔订单。
说明/提示
For the first sample test case, the factory can produce $5$ products each day.
- At the end of day $1$, there are $5$ products in stock so the factory can complete the $2$-nd order. After delivery, there are $2$ products left in stock.
- At the end of day $6$, the factory produces $25$ more products. There are $27$ products in stock so the factory can complete the $1$-st and the $3$-rd order. After delivery, there are $0$ products left in stock.
- At the end of day $8$, the factory produces $10$ more products. There are $10$ products in stock so the factory can complete the $4$-th order. After delivery, there are $9$ products left in stock.
For the second sample test case, the factory can produce $100$ products each day.
- At the end of day $3$, there are $300$ products in stock and the factory can complete the $1$-st order. After delivery, there are $100$ products left in stock.
- At the end of day $4$, the factory produces $100$ more products. There are only $200$ products in stock so the factory cannot complete the $2$-nd order.