CF2117A.False Alarm

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

False Alarm

Yousef is at the entrance of a long hallway with nn doors in a row, numbered from 11 to nn. He needs to pass through all the doors from 11 to nn in order of numbering and reach the exit (past door nn).

Each door can be open or closed. If a door is open, Yousef passes through it in 11 second. If the door is closed, Yousef can't pass through it.

However, Yousef has a special button which he can use at most once at any moment. This button makes all closed doors become open for xx seconds.

Your task is to determine if Yousef can pass through all the doors if he can use the button at most once.

Input

The first line of the input contains an integer tt (1t10001 \le t \le 1000) — the number of test cases.

The first line of each test case contains two integers n,xn, x (1n,x101 \le n, x \le 10) — the number of doors and the number of seconds of the button, respectively.

The second line of each test case contains nn integers a1,a2,...,ana_1, a_2, ..., a_n (ai{0,1}a_i \in \{0, 1\}) — the state of each door. Open doors are represented by '0', while closed doors are represented by '1'.

It is guaranteed that each test case contains at least one closed door.

Output

For each test case, output "YES" if Yousef can reach the exit, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

In the first test case, the optimal way is as follows:

  • At time 00, the door is open, so Yousef passes.
  • At time 11, the door is closed, Yousef can use the button now and pass through the door.
  • At time 22, the button's effect is still on, so Yousef can still pass.
  • At time 33, the button's effect has finished, but the door is open. Yousef passes and reaches the exit.

In the second test case, Yousef has a 3-second button, but he would need at least a 4-second button to reach the exit. Therefore, the answer is NO.

In the third test case, Yousef can turn on the button before starting to move. All the doors will stay open until he reaches the exit.

Samples

7
4 2
0 1 1 0
6 3
1 0 1 1 0 0
8 8
1 1 1 0 0 1 1 1
1 2
1
5 1
1 0 1 0 1
7 4
0 0 0 1 1 0 1
10 3
0 1 0 0 1 0 0 1 0 0
YES
NO
YES
YES
NO
YES
NO

在线编程 IDE

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