CF1668B.Social Distance

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Social Distance

mm chairs are arranged in a circle sequentially. The chairs are numbered from 00 to m1m-1. nn people want to sit in these chairs. The ii-th of them wants at least a[i]a[i] empty chairs both on his right and left side.

More formally, if the ii-th person sits in the jj-th chair, then no one else should sit in the following chairs: (ja[i])modm(j-a[i]) \bmod m, (ja[i]+1)modm(j-a[i]+1) \bmod m, ... (j+a[i]1)modm(j+a[i]-1) \bmod m, (j+a[i])modm(j+a[i]) \bmod m.

Decide if it is possible to sit down for all of them, under the given limitations.

Input

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

The first line of each test case contains two integers nn and mm (2n1052 \leq n \leq 10^5, 1m1091 \leq m \leq 10^9) — the number of people and the number of chairs.

The next line contains nn integers, a1a_1, a2a_2, ... ana_n (1ai1091 \leq a_i \leq 10^9) — the minimum number of empty chairs, on both sides of the ii-th person.

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

Output

For each test case print "YES" (without quotes) if it is possible for everyone to sit down and fulfil the restrictions, and "NO" (without quotes) otherwise.

You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes" and "YES" will all be recognized as positive answers).

Note

Test case 11: n>mn \gt m, so they can not sit down.

Test case 22: the first person can sit 22-nd and the second person can sit in the 00-th chair. Both of them want at least 11 empty chair on both sides, chairs 11 and 33 are free, so this is a good solution.

Test case 33: if the second person sits down somewhere, he needs 22 empty chairs, both on his right and on his left side, so it is impossible to find a place for the first person, because there are only 55 chairs.

Test case 44: they can sit in the 11-st, 44-th, 77-th chairs respectively.

Samples

6
3 2
1 1 1
2 4
1 1
2 5
2 1
3 8
1 2 1
4 12
1 2 1 3
4 19
1 2 1 3
NO
YES
NO
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验