#K92207. Good Path Verification
Good Path Verification
Good Path Verification
You are given a collection of N integers along with three additional integers: S, E, and X. Your task is to determine whether the subarray (or "path") from index S to E (1-indexed) satisfies the following conditions:
1. The subarray is non-decreasing. That is, for all indices \( i \) where \( S \leq i < E \), the condition \( a_i \leq a_{i+1} \) holds.
2. The sum of the elements in the subarray is at least \( X \), i.e., \( \sum_{i=S}^{E} a_i \geq X \).
If both conditions are met, output YES; otherwise, output NO.
inputFormat
The first line contains four space-separated integers: N, S, E, and X.
The second line contains N space-separated integers representing the collection.
outputFormat
Output a single line containing YES if the subarray from S to E is non-decreasing and its sum is at least X; otherwise, output NO.
## sample6 2 5 10
1 2 3 4 5 6
YES
</p>