#P9556. [SDCPC2023] Orders

[SDCPC2023] Orders

题目描述

A factory receives nn orders at the beginning of day 11. The ii-th order can be described as two integers aia_i and bib_i, indicating that at the end of day aia_i, the factory needs to deliver bib_i products to the customer.

Given that the factory can produce kk products each day, and at the beginning of day 11 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 TT (1T1001 \le T \le 100) indicating the number of test cases. For each test case:

The first line contains two integers nn and kk (1n1001 \le n \le 100, 1k1091 \le k \le 10^9) indicating the number of orders and the number of products the factory can produce each day.

For the following nn lines, the ii-th line contains two integers aia_i and bib_i (1ai,bi1091 \le a_i, b_i \le 10^9) indicating that the ii-th order require the factory to deliver bib_i products at the end of day aia_i.

输出格式

For each test case output one line. If the factory can complete all orders output Yes\texttt{Yes}, otherwise output No\texttt{No}.

题目大意

【题目描述】

某工厂在第 11 天开工之前收到了 nn 笔订单,第 ii 笔订单可以用两个整数 aia_ibib_i 描述,表示工厂需要在第 aia_i 天结束时交付 bib_i 件货物。

已知工厂每天能生产 kk 件货物,且第 11 天开工之前没有任何存货,问该工厂能否完成所有订单。

【输入格式】

有多组测试数据。第一行输入一个整数 TT1T1001 \le T \le 100)表示测试数据组数,对于每组测试数据:

第一行输入两个整数 nnkk1n1001 \le n \le 1001k1091 \le k \le 10^9)表示订单数量以及工厂每日能生产的货物数量。

对于接下来 nn 行,第 ii 行输入两个整数 aia_ibib_i1ai,bi1091 \le a_i, b_i \le 10^9)表示第 ii 笔订单要求在第 aia_i 天结束时交付 bib_i 件货物。

【输出格式】

每组数据输出一行。若工厂能完成所有订单输出 Yes\texttt{Yes},否则输出 No\texttt{No}

【样例解释】

对于第一组样例数据,工厂每天能生产 55 件货物。

  • 在第 11 天结束时,工厂共有 55 件货物,可以完成第 22 笔订单。交付后,工厂剩余 22 件货物。
  • 在第 66 天结束时,工厂又多生产了 2525 件货物,共有 2727 件货物,可以完成第 11 和第 33 笔订单。交付后,工厂剩余 00 件货物。
  • 在第 88 天结束时,工厂又多生产了 1010 件货物,共有 1010 件货物,可以完成第 44 笔订单。交付后,工厂剩余 99 件货物。

对于第二组样例数据,工厂每天能生产 100100 件货物。

  • 在第 33 天结束时,工厂共有 300300 件货物,可以完成第 11 笔订单。交付后,工厂剩余 100100 件货物。
  • 在第 44 天结束时,工厂又多生产了 100100 件货物,共有 200200 件货物,无法完成第 22 笔订单。
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 55 products each day.

  • At the end of day 11, there are 55 products in stock so the factory can complete the 22-nd order. After delivery, there are 22 products left in stock.
  • At the end of day 66, the factory produces 2525 more products. There are 2727 products in stock so the factory can complete the 11-st and the 33-rd order. After delivery, there are 00 products left in stock.
  • At the end of day 88, the factory produces 1010 more products. There are 1010 products in stock so the factory can complete the 44-th order. After delivery, there are 99 products left in stock.

For the second sample test case, the factory can produce 100100 products each day.

  • At the end of day 33, there are 300300 products in stock and the factory can complete the 11-st order. After delivery, there are 100100 products left in stock.
  • At the end of day 44, the factory produces 100100 more products. There are only 200200 products in stock so the factory cannot complete the 22-nd order.