Codeforces Round 1091 (Div. 2) and CodeCraft 26
A
The Equalizer
Codeforces
800
原题
←B →
翻译中…

To settle a long-time feud, Shaunak and Yash decided to play a game on an array $a$ of $n$ 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 $a_i \gt 0$ and decrements it by $1$.

翻译中…

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 $a_i$ ($1 \leq i \leq n$) are set to a special value $k$ 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 $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

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

翻译中…

The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($1 \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 = 3$, $k = 2$ and the initial array is $[3, 3, 3]$. One possible way the game could proceed is shown:

翻译中…
  • Shaunak decrements $a_3$. Array becomes $[3, 3, 2]$.
  • Yash decrements $a_3$. Array becomes $[3, 3, 1]$.
  • Shaunak uses the special move. Array becomes $[2, 2, 2]$.
  • Yash decrements $a_1$. Array becomes $[1, 2, 2]$.
  • Shaunak decrements $a_2$. Array becomes $[1, 1, 2]$.
  • Yash decrements $a_3$. Array becomes $[1, 1, 1]$.
  • Shaunak decrements $a_1$. Array becomes $[0, 1, 1]$.
  • Yash decrements $a_3$. Array becomes $[0, 1, 0]$.
  • Shaunak decrements $a_2$. Array becomes $[0, 0, 0]$.
翻译中…

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

翻译中…

样例

Input #1
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
Output #1
YES
YES
YES
NO
InputCopy OutputCopy
题目信息
题号
2217A
时间限制
1 s
内存限制
256 MB
标签
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。