Suffering

View as PDF

Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Problem Statement

Josh does not like research. In particular, he can model the n FIT2083 classes of the semester as an array, of which the i-th value is equal to the number of Depression Points he will gain from attending it. Furthermore, Josh knows that if the number of Depression Points he obtains exceeds k, he will die.

Given this array, Josh wonders: What is the smallest number of consecutive classes he can attend and die as a result?

Input Format

The first line of the input will consist of two integers, n and k. The second line of input will consist of n numbers, representing the array described in the problem.

Output Format

Output a single integer, the smallest number of consecutive classes he can attend in order to die. If this is not possible, output -1.

Constraints

1 \le n \le 1e5

1 \le k \le 1e6

1 \le a[i] \le 1e3

Sample Input 1

5 11
5 10 1 4 5

Sample Output 1

2

Sample Explanation 1

The shortest window of classes with a sum of Depression Points exceeding 11 is the first and second element, which is of length 2.


Comments

There are no comments at the moment.