CF1668B.Social Distance
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
m chairs are arranged in a circle sequentially. The chairs are numbered from 0 to m−1 . n people want to sit in these chairs. The i -th of them wants at least a[i] empty chairs both on his right and left side.
More formally, if the i -th person sits in the j -th chair, then no one else should sit in the following chairs: (j−a[i])modm , (j−a[i]+1)modm , ... (j+a[i]−1)modm , (j+a[i])modm .
Decide if it is possible to sit down for all of them, under the given limitations.
输入格式
The input consists of multiple test cases. The first line contains a single integer t ( 1≤t≤5⋅104 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers n and m ( 2≤n≤105 , 1≤m≤109 ) — the number of people and the number of chairs.
The next line contains n integers, a1 , a2 , ... an ( 1≤ai≤109 ) — the minimum number of empty chairs, on both sides of the i -th person.
It is guaranteed that the sum of n over all test cases will not exceed 105 .
输出格式
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).
输入输出样例
输入#1
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
输出#1
NO YES NO YES NO YES
说明/提示
Test case 1 : n>m , so they can not sit down.
Test case 2 : the first person can sit 2 -nd and the second person can sit in the 0 -th chair. Both of them want at least 1 empty chair on both sides, chairs 1 and 3 are free, so this is a good solution.
Test case 3 : if the second person sits down somewhere, he needs 2 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 5 chairs.
Test case 4 : they can sit in the 1 -st, 4 -th, 7 -th chairs respectively.