CF1759B.Lost Permutation

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

Lost Permutation

A sequence of nn numbers is called a permutation if it contains all integers from 11 to nn exactly once. For example, the sequences [3,1,4,23, 1, 4, 2], [11] and [2,12,1] are permutations, but [1,2,11,2,1], [0,10,1] and [1,3,41,3,4] — are not.

Polycarp lost his favorite permutation and found only some of its elements — the numbers b1,b2,bmb_1, b_2, \dots b_m. He is sure that the sum of the lost elements equals ss.

Determine whether one or more numbers can be appended to the given sequence b1,b2,bmb_1, b_2, \dots b_m such that the sum of the added numbers equals ss, and the resulting new array is a permutation?

Input

The first line of input contains a single integer tt (1t1001 \le t \le 100) —the number of test cases.

Then the descriptions of the test cases follow.

The first line of each test set contains two integers mm and ss (1m501 \le m \le 50, 1s10001 \le s \le 1000)—-the number of found elements and the sum of forgotten numbers.

The second line of each test set contains mm different integers b1,b2bmb_1, b_2 \dots b_m (1bi501 \le b_i \le 50) — the elements Polycarp managed to find.

Output

Print tt lines, each of which is the answer to the corresponding test set. Print as the answer YES if you can append several elements to the array bb, that their sum equals ss and the result will be a permutation. Output NO otherwise.

You can output the answer in any case (for example, yEs, yes, Yes and YES will be recognized as positive answer).

Note

In the test case of the example, m=3,s=13,b=[3,1,4]m=3, s=13, b=[3,1,4]. You can append to bb the numbers 6,2,56,2,5, the sum of which is 6+2+5=136+2+5=13. Note that the final array will become [3,1,4,6,2,5][3,1,4,6,2,5], which is a permutation.

In the second test case of the example, m=1,s=1,b=[1]m=1, s=1, b=[1]. You cannot append one or more numbers to [1][1] such that their sum equals 11 and the result is a permutation.

In the third test case of the example, m=3,s=3,b=[1,4,2]m=3, s=3, b=[1,4,2]. You can append the number 33 to bb. Note that the resulting array will be [1,4,2,3][1,4,2,3], which is a permutation.

Samples

5
3 13
3 1 4
1 1
1
3 3
1 4 2
2 1
4 3
5 6
1 2 3 4 5
YES
NO
YES
NO
YES

在线编程 IDE

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