CF1436A.Reorder

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

Reorder

For a given array aa consisting of nn integers and a given integer mm find if it is possible to reorder elements of the array aa in such a way that umi=1numj=inajjum_{i=1}^{n}{ um_{j=i}^{n}{\frac{a_j}{j}}} equals mm? It is forbidden to delete elements as well as insert new elements. Please note that no rounding occurs during division, for example, 52=2.5\frac{5}{2}=2.5.

Input

The first line contains a single integer tt — the number of test cases (1t1001 \le t \le 100). The test cases follow, each in two lines.

The first line of a test case contains two integers nn and mm (1n1001 \le n \le 100, 0m1060 \le m \le 10^6). The second line contains integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai1060 \le a_i \le 10^6) — the elements of the array.

Output

For each test case print "YES", if it is possible to reorder the elements of the array in such a way that the given formula gives the given value, and "NO" otherwise.

Note

In the first test case one of the reorders could be [1,2,5][1, 2, 5]. The sum is equal to $(\frac{1}{1} + \frac{2}{2} + \frac{5}{3}) + (\frac{2}{2} + \frac{5}{3}) + (\frac{5}{3}) = 8$. The brackets denote the inner sum umj=inajjum_{j=i}^{n}{\frac{a_j}{j}}, while the summation of brackets corresponds to the sum over ii.

Samples

2
3 8
2 5 1
4 4
0 1 2 3
YES
NO

在线编程 IDE

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