CF1774B.Coloring
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Cirno_9baka has a paper tape with n cells in a row on it. As he thinks that the blank paper tape is too dull, he wants to paint these cells with m kinds of colors. For some aesthetic reasons, he thinks that the i -th color must be used exactly ai times, and for every k consecutive cells, their colors have to be distinct.
Help Cirno_9baka to figure out if there is such a way to paint the cells.
输入格式
The first line contains a single integer t ( 1≤t≤10000 ) — the number of test cases. The description of test cases follows.
The first line of each test case contains three integers n , m , k ( 1≤k≤n≤109 , 1≤m≤105 , m≤n ). Here n denotes the number of cells, m denotes the number of colors, and k means that for every k consecutive cells, their colors have to be distinct.
The second line of each test case contains m integers a1,a2,⋯,am ( 1≤ai≤n ) — the numbers of times that colors have to be used. It's guaranteed that a1+a2+…+am=n .
It is guaranteed that the sum of m over all test cases does not exceed 105 .
输出格式
For each test case, output "YES" if there is at least one possible coloring scheme; otherwise, output "NO".
You may print each letter in any case (for example, "YES", "Yes", "yes", and "yEs" will all be recognized as positive answers).
输入输出样例
输入#1
2 12 6 2 1 1 1 1 1 7 12 6 2 2 2 2 2 2 2
输出#1
NO YES
说明/提示
In the first test case, there is no way to color the cells satisfying all the conditions.
In the second test case, we can color the cells as follows: (1,2,1,2,3,4,3,4,5,6,5,6) . For any 2 consecutive cells, their colors are distinct.