#K67487. Subarray with Given Sum

    ID: 32653 Type: Default 1000ms 256MiB

Subarray with Given Sum

Subarray with Given Sum

Given an array of integers and a target integer (k), determine if there exists a contiguous subarray whose sum is exactly (k). A contiguous subarray is a sequence of consecutive elements (a_l, a_{l+1}, \ldots, a_r) such that (\sum_{i=l}^{r} a_i = k). You are given multiple test cases. For each test case, output "YES" if such a subarray exists, and "NO" otherwise.

inputFormat

The first line 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 size of the array and (k) is the target sum. The second line contains (n) space-separated integers representing the array elements.

outputFormat

For each test case, output a single line containing "YES" if there exists a contiguous subarray with sum equal to (k), or "NO" if there does not exist such a subarray.## sample

3
5 12
1 2 3 7 5
10 3
1 2 3 4 5 6 7 8 9 10
4 -10
1 -1 -1 -1
YES

YES NO

</p>