A financial ledger records the net cash change for each of n consecutive days as an integer (a deposit is positive, a withdrawal is negative). Find the length of the SHORTEST contiguous run of days whose total net change is at least a required reserve K. If no contiguous run reaches K, print -1.
Because daily changes may be negative, a simple two-pointer window is not sufficient in general — a shorter run appearing later could have a smaller total than a longer run, so you may need to reconsider candidate starting points as you scan forward.
Input format
Line 1: two integers n and K.
Line 2: n space-separated integers, the daily net cash changes.
Output format
A single integer: the minimal length of a contiguous run summing to at least K, or -1 if no such run exists.
Constraints
- 1 ≤ n ≤ 100000
- -1000 ≤ daily change ≤ 1000
- -1000000000 ≤ K ≤ 1000000000