luogu#P9556. [SDCPC2023] Orders
[SDCPC2023] Orders
题目描述
A factory receives orders at the beginning of day . The -th order can be described as two integers and , indicating that at the end of day , the factory needs to deliver products to the customer.
Given that the factory can produce products each day, and at the beginning of day the factory has no product in stock, can the factory complete all orders?
输入格式
There are multiple test cases. The first line of the input contains an integer () indicating the number of test cases. For each test case:
The first line contains two integers and (, ) indicating the number of orders and the number of products the factory can produce each day.
For the following lines, the -th line contains two integers and () indicating that the -th order require the factory to deliver products at the end of day .
输出格式
For each test case output one line. If the factory can complete all orders output , otherwise output .
题目大意
【题目描述】
某工厂在第 天开工之前收到了 笔订单,第 笔订单可以用两个整数 和 描述,表示工厂需要在第 天结束时交付 件货物。
已知工厂每天能生产 件货物,且第 天开工之前没有任何存货,问该工厂能否完成所有订单。
【输入格式】
有多组测试数据。第一行输入一个整数 ()表示测试数据组数,对于每组测试数据:
第一行输入两个整数 和 (,)表示订单数量以及工厂每日能生产的货物数量。
对于接下来 行,第 行输入两个整数 和 ()表示第 笔订单要求在第 天结束时交付 件货物。
【输出格式】
每组数据输出一行。若工厂能完成所有订单输出 ,否则输出 。
【样例解释】
对于第一组样例数据,工厂每天能生产 件货物。
- 在第 天结束时,工厂共有 件货物,可以完成第 笔订单。交付后,工厂剩余 件货物。
- 在第 天结束时,工厂又多生产了 件货物,共有 件货物,可以完成第 和第 笔订单。交付后,工厂剩余 件货物。
- 在第 天结束时,工厂又多生产了 件货物,共有 件货物,可以完成第 笔订单。交付后,工厂剩余 件货物。
对于第二组样例数据,工厂每天能生产 件货物。
- 在第 天结束时,工厂共有 件货物,可以完成第 笔订单。交付后,工厂剩余 件货物。
- 在第 天结束时,工厂又多生产了 件货物,共有 件货物,无法完成第 笔订单。
2
4 5
6 12
1 3
6 15
8 1
3 100
3 200
4 300
6 100
Yes
No
提示
For the first sample test case, the factory can produce products each day.
- At the end of day , there are products in stock so the factory can complete the -nd order. After delivery, there are products left in stock.
- At the end of day , the factory produces more products. There are products in stock so the factory can complete the -st and the -rd order. After delivery, there are products left in stock.
- At the end of day , the factory produces more products. There are products in stock so the factory can complete the -th order. After delivery, there are products left in stock.
For the second sample test case, the factory can produce products each day.
- At the end of day , there are products in stock and the factory can complete the -st order. After delivery, there are products left in stock.
- At the end of day , the factory produces more products. There are only products in stock so the factory cannot complete the -nd order.