Codeforces Global Round 14
A
Phoenix and Gold
Codeforces
800
原题
←B →
翻译中…

Phoenix has collected $n$ pieces of gold, and he wants to weigh them together so he can feel rich. The $i$-th piece of gold has weight $w_i$. All weights are distinct. He will put his $n$ pieces of gold on a weight scale, one piece at a time.

翻译中…

The scale has an unusual defect: if the total weight on it is exactly $x$, it will explode. Can he put all $n$ gold pieces onto the scale in some order, without the scale exploding during the process? If so, help him find some possible order.

翻译中…

Formally, rearrange the array $w$ so that for each $i$ $(1 \le i \le n)$, $\sum\limits_{j = 1}^{i}w_j \ne x$.

翻译中…

Input

翻译中…

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

翻译中…

The first line of each test case contains two integers $n$ and $x$ ($1 \le n \le 100$; $1 \le x \le 10^4$) — the number of gold pieces that Phoenix has and the weight to avoid, respectively.

翻译中…

The second line of each test case contains $n$ space-separated integers $(1 \le w_i \le 100)$ — the weights of the gold pieces. It is guaranteed that the weights are pairwise distinct.

翻译中…

Output

翻译中…

For each test case, if Phoenix cannot place all $n$ pieces without the scale exploding, print NO. Otherwise, print YES followed by the rearranged array $w$. If there are multiple solutions, print any.

翻译中…

Note

翻译中…

In the first test case, Phoenix puts the gold piece with weight $3$ on the scale first, then the piece with weight $2$, and finally the piece with weight $1$. The total weight on the scale is $3$, then $5$, then $6$. The scale does not explode because the total weight on the scale is never $2$.

翻译中…

In the second test case, the total weight on the scale is $8$, $9$, $11$, $14$, then $18$. It is never $3$.

翻译中…

In the third test case, Phoenix must put the gold piece with weight $5$ on the scale, and the scale will always explode.

翻译中…

样例

Input #1
3
3 2
3 2 1
5 3
1 2 3 4 8
1 5
5
Output #1
YES
3 2 1
YES
8 1 2 3 4
NO
InputCopy OutputCopy
题目信息
题号
1515A
时间限制
2 s
内存限制
256 MB
标签
构造
贪心
数学

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