题库练习 Doremy's Number Line
← 上一题 下一题 →

A15483 | Doremy's Number Line

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Doremy has two arrays $a$ and $b$ of $n$ integers each, and an integer $k$ .

Initially, she has a number line where no integers are colored. She chooses a permutation $p$ of $[1,2,\ldots,n]$ then performs $n$ moves. On the $i$ -th move she does the following:

- Pick an uncolored integer $x$ on the number line such that either:
- $x \leq a_{p_i}$ ; or
- there exists a colored integer $y$ such that $y \leq a_{p_i}$ and $x \leq y+b_{p_i}$ .
- Color integer $x$ with color $p_i$ .

Determine if the integer $k$ can be colored with color $1$ .

输入格式

The input consists of multiple test cases. The first line contains a single integer $t$ ( $1\le t\le 10^4$ ) — the number of test cases. The description of the test cases follows.

The first line contains two integers $n$ and $k$ ( $1 \le n \le 10^5$ , $1 \le k \le 10^9$ ).

Each of the following $n$ lines contains two integers $a_i$ and $b_i$ ( $1 \le a_i,b_i \le 10^9$ ).

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .

输出格式

For each test case, output "YES" (without quotes) if the point $k$ can be colored with color $1$ . Otherwise, output "NO" (without quotes).

You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

输入输出样例

输入 #1
6
4 16
5 3
8 12
10 7
15 1
4 16
8 12
10 7
15 1
5 3
4 16
10 7
15 1
5 3
8 12
4 16
15 1
5 3
8 12
10 7
1 1000000000
500000000 500000000
2 1000000000
1 999999999
1 1
输出 #1
NO
YES
YES
YES
NO
YES
C++ 编辑器
输入
输出