#C7709. Split Array into Subarrays with Sufficient Sum
Split Array into Subarrays with Sufficient Sum
Split Array into Subarrays with Sufficient Sum
You are given an array of positive integers and an integer k. Your task is to determine if the array can be split into one or more non-overlapping subarrays such that the sum of the elements in each subarray is greater than or equal to k.
Input Format: The first line contains two integers n and k — the number of elements in the array and the threshold sum respectively. The second line contains n space-separated integers representing the elements of the array.
Output Format: Output a single line with "YES" if it is possible to split the array as described, or "NO" otherwise.
Note: The subarrays must consist of consecutive elements from the original array, and once a subarray is formed (when its sum reaches or exceeds k), you start forming the next subarray from the subsequent elements.
inputFormat
The input is given from standard input (stdin) and consists of two lines. The first line contains two integers n and k. The second line contains n space-separated integers representing the array.
outputFormat
Output to standard output (stdout) a single string: either "YES" if the array can be split into subarrays where each subarray has a sum greater than or equal to k, or "NO" if it cannot.
## sample6 10
1 2 3 4 5 6
YES