| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given an array a0, a1, …, an − 1 of integers (may include negatives) and an integer k. Find the length of the shortest non-empty contiguous subarray whose sum is ≥ k, or report − 1 if no such subarray exists.
The first line contains two integers n and k. The second line contains n space-separated integers a0… an − 1.
Print one integer: the shortest length, or − 1.
1 ≤ n ≤ 2 ⋅ 105
− 1000 ≤ ai ≤ 1000
− 109 ≤ k ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|