#K74632. Exact Pastry Purchase

    ID: 34241 Type: Default 1000ms 256MiB

Exact Pastry Purchase

Exact Pastry Purchase

You are given a bakery with N types of pastries and a customer who wants to buy exactly K units of pastries. For each type of pastry, you are provided the number of available units. Your task is to determine whether there exists a subset of these pastry types whose total number of units is exactly equal to K.

This problem is a classic subset sum problem. Mathematically, given an array \(U = [u_1, u_2, \dots, u_N]\) and an integer \(K\), determine if there exists a subset \(S \subseteq \{1, 2, \dots, N\}\) such that \[ \sum_{i \in S} u_i = K \]

If such a subset exists, print Yes; otherwise, print No.

inputFormat

The input begins with a single integer T on the first line, representing the number of test cases.

For each test case:

  • The first line contains two integers: N (the number of pastry types) and K (the exact number of pastry units desired).
  • The second line contains N space-separated integers, representing the available units for each pastry type.

You need to check for every test case if there exists a subset of these N numbers that sums exactly to K.

outputFormat

For each test case, output a single line containing Yes if it is possible to purchase exactly K units of pastries, otherwise output No.

## sample
1
3 5
2 3 4
Yes

</p>