#K84617. Positive Subarray Sum
Positive Subarray Sum
Positive Subarray Sum
You are given an array of n integers and an integer k. Your task is to determine whether there exists a subarray of exactly length k whose sum is positive. A subarray is a contiguous segment of the array.
Example:
Input: 5 3 1 -2 3 4 -1</p>Output: YES
In the example above, the subarray [3, 4, -1] has a sum of 6, which is positive.
inputFormat
The first line of the input contains two integers n and k where n is the number of elements in the array and k is the required subarray length. The second line contains n space-separated integers representing the array elements.
outputFormat
Output a single line containing "YES" if there is at least one subarray of length exactly k with a positive sum. Otherwise, output "NO".## sample
5 3
1 -2 3 4 -1
YES