P18561 [CodeChef] FIXWEIGHT
提高-
题目描述

A permutation of length N is an array of $N integers (P_{1},P_{2}, \dots,P_{N})$ where every integer from 1 to N (inclusive) appears in it exactly once. The weight of a subsegment containing the elements $(P_{l},P_{l+1}, \dots,P_{r})$ is defined as follows: $W(l, r) = (r-l+1)\cdot \min\limits_{l$≤ i ≤ r} (P_{i})
where 1≤ l ≤ r ≤ N and $\min\limits_{l$≤ i ≤ r} (P_{i}) denotes the minimum element of the subsegment.

You are given two integers N and X. You need to determine if there exists a permutation of length N such that it contains at least one subsegment having weight X?

------ Input Format ------

  • The first line contains an integer T - the number of test cases. The T test cases then follow.
  • The first and only line of each test case contains two space-separated integers N, X - the length of the permutation and the weight parameter mentioned in the question respectively.

------ Output Format ------

For each test case, print YES if there exists a permutation of length N having at least one subsegment with a weight of X, otherwise print NO.

You may print each character of Yes and No in uppercase or lowercase (for example, yes, yEs, YES will be considered identical).

------ Constraints ------

$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ X ≤ 10^{10}$
- Sum of $N$ over all test cases does not exceed $3 \cdot 10^{5}$.

----- Sample Input 1 ------
4
3 2
3 5
5 6
4 10

----- Sample Output 1 ------
YES
NO
YES
NO

----- explanation 1 ------
Test case $1$: $[1, 2, 3]$ is one of the valid permutations because it contains the following subsegment having weight $2$.

$W(1, 2) = (2-1+1) \cdot \min\limits_{1≤ i ≤ 2} (P_{i})= 2 \cdot 1=2$

Test case $2$: It can be proven that there does not exist any permutation of length $3$ which has a subsegment having weight $5$.

Test case $3$: $[4, 2, 1, 3, 5]$ is one of the valid permutations because it contains the following subsegment having weight $6$.

$W(4, 5)=(5-4+1) \cdot \min\limits_{4≤ i ≤ 5} (P_{i})= 2 \cdot 3=6$

输入格式

见题面

输出格式

见题面

样例输入
4 3 2 3 5 5 6 4 10
样例输出
YES NO YES NO