#C10999. Taco Subset Sum Problem
Taco Subset Sum Problem
Taco Subset Sum Problem
You are given an array of n positive integers and an integer target value K. Your task is to determine whether there exists a subset of the given array whose sum is exactly K.
This is a classic Subset Sum problem which can be stated in mathematical terms as follows:
Find a subset \( S \) of the set of integers \( A = \{ a_1, a_2, \dots, a_n \} \) such that:
\[ \sum_{a \in S} a = K \]
If such a subset exists, output "Yes"; otherwise, output "No".
Note: The solution is expected to work for multiple test cases. The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line of input contains an integer T, the number of test cases. For each test case, the first line contains two integers N and K, where N is the number of elements in the array and K is the target sum. The next line contains N space-separated integers representing the elements of the array.
outputFormat
For each test case, output a single line containing "Yes" if there exists a subset with sum equal to K, and "No" otherwise.## sample
2
4 10
2 3 7 8
5 9
1 5 3 4 2
Yes
Yes
</p>