CF2217A.The Equalizer

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

The Equalizer

To settle a long-time feud, Shaunak and Yash decided to play a game on an array aa of nn integers, with Shaunak going first. The players take turns, and the last player to make a move wins. On a player's turn, he chooses some ai>0a_i \gt 0 and decrements it by 11.

To make things interesting, Shaunak is allowed to use a special move at most once during the game. This move replaces his normal turn. When used, all elements aia_i (1in1 \leq i \leq n) are set to a special value kk that is given initially.

Assuming that both players play optimally, determine if Shaunak can always win.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains two integers nn and kk (1n1001 \leq n \leq 100, 1k5001 \leq k \leq 500), denoting the size of the array and the special value.

The second line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai1031 \leq a_i \leq 10^3).

Output

For each test case, print "YES" if Shaunak can always win, 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 third test case, n=3n = 3, k=2k = 2 and the initial array is [3,3,3][3, 3, 3]. One possible way the game could proceed is shown:

  • Shaunak decrements a3a_3. Array becomes [3,3,2][3, 3, 2].
  • Yash decrements a3a_3. Array becomes [3,3,1][3, 3, 1].
  • Shaunak uses the special move. Array becomes [2,2,2][2, 2, 2].
  • Yash decrements a1a_1. Array becomes [1,2,2][1, 2, 2].
  • Shaunak decrements a2a_2. Array becomes [1,1,2][1, 1, 2].
  • Yash decrements a3a_3. Array becomes [1,1,1][1, 1, 1].
  • Shaunak decrements a1a_1. Array becomes [0,1,1][0, 1, 1].
  • Yash decrements a3a_3. Array becomes [0,1,0][0, 1, 0].
  • Shaunak decrements a2a_2. Array becomes [0,0,0][0, 0, 0].

Since there are no ai>0a_i \gt 0 remaining, Yash cannot make any further moves and Shaunak wins.

Samples

4
1 1
1
2 67
67 67
3 2
3 3 3
11 3
1 2 3 4 5 6 7 8 9 10 11
YES
YES
YES
NO

在线编程 IDE

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