CF1764E.Doremy's Number Line

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Doremy has two arrays aa and bb of nn integers each, and an integer kk .

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

  • Pick an uncolored integer xx on the number line such that either:
    • xapix \leq a_{p_i} ; or
    • there exists a colored integer yy such that yapiy \leq a_{p_i} and xy+bpix \leq y+b_{p_i} .
  • Color integer xx with color pip_i .

Determine if the integer kk can be colored with color 11 .

输入格式

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

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

Each of the following nn lines contains two integers aia_i and bib_i ( 1ai,bi1091 \le a_i,b_i \le 10^9 ).

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case, output "YES" (without quotes) if the point kk can be colored with color 11 . 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

说明/提示

For the first test case, it is impossible to color point 1616 with color 11 .

For the second test case, p=[2,1,3,4]p=[2,1,3,4] is one possible choice, the detail is shown below.

  • On the first move, pick x=8x=8 and color it with color 22 since x=8x=8 is uncolored and xa2x \le a_2 .
  • On the second move, pick x=16x=16 and color it with color 11 since there exists a colored point y=8y=8 such that ya1y\le a_1 and xy+b1x \le y + b_1 .
  • On the third move, pick x=0x=0 and color it with color 33 since x=0x=0 is uncolored and xa3x \le a_3 .
  • On the forth move, pick x=2x=-2 and color it with color 44 since x=2x=-2 is uncolored and xa4x \le a_4 .
  • In the end, point 2,0,8,16-2,0,8,16 are colored with color 4,3,2,14,3,2,1 , respectively.

For the third test case, p=[2,1,4,3]p=[2,1,4,3] is one possible choice.

For the fourth test case, p=[2,3,4,1]p=[2,3,4,1] is one possible choice.

首页