#C4243. Subarray Sum Existence
Subarray Sum Existence
Subarray Sum Existence
In this problem, you are given an array of integers and a target sum requirement. For each test case, determine whether there exists a contiguous subarray of length exactly (K) whose sum is greater than or equal to (X). If such a subarray exists, print "YES"; otherwise, print "NO".
Note: The subarray must be exactly of length (K). Use an efficient sliding window algorithm to solve the problem, as large arrays may be provided in the input.
inputFormat
The input is read from standard input (stdin).
The first line contains an integer (T), the number of test cases. Each test case consists of two lines:
1. The first line contains three integers (N), (K), and (X) where (N) is the size of the array, (K) is the required subarray length, and (X) is the target sum.
2. The second line contains (N) space-separated integers representing the array elements.
outputFormat
For each test case, output a single line on standard output (stdout) containing either "YES" if there exists a contiguous subarray of length exactly (K) with a sum greater than or equal to (X), or "NO" otherwise.## sample
3
5 3 15
1 2 3 7 8
4 4 10
1 1 1 1
6 2 7
4 5 1 2 3 9
YES
NO
YES
</p>