#K68342. Subsequence Sum Problem

    ID: 32843 Type: Default 1000ms 256MiB

Subsequence Sum Problem

Subsequence Sum Problem

You are given a sequence of integers and a target sum T. Your task is to determine whether there exists a non-empty subset of the sequence whose elements sum exactly to T. A subset is any selection of elements (the elements do not need to be consecutive).

The input starts with an integer indicating the number of test cases. For each test case, the first line contains two integers: n, the number of elements in the sequence, and T, the target sum. The following line contains n space-separated integers representing the sequence.

For each test case, print YES if there exists at least one subset whose sum equals T, or NO otherwise.

inputFormat

The first line contains an integer T representing the number of test cases. Each test case consists of two lines. The first line contains two integers n and T where n is the size of the sequence and T is the target sum. The second line contains n space-separated integers denoting the sequence.

outputFormat

For each test case, output a single line with YES if there exists a non-empty subset whose sum is exactly equal to the target value T, otherwise output NO.

## sample
4
5 9
1 2 3 4 5
4 11
9 3 2 1
3 3
2 2 2
6 15
1 2 3 4 5 15
YES

YES NO YES

</p>