Day 3: Buying Chocolate Boxes

medium
You are at a store where there are NN boxes of chocolates placed in a row. Each box contains a positive number of chocolates (no empty box).
You want to buy a group of consecutive boxes such that the total number of chocolates is exactly KK. Among all such possible groups, you want the minimum\bf{minimum} number of boxes.

NOTE:\bf{NOTE:} If there is no such group, return 1-1.

Input Format:

First line: Two integers NN \text{---} number of boxes (1N1051 \leq N \leq 10^5) and KK \text{---} number of required chocolates (1K10181 \leq K \leq 10^{18})
Second line: NN integers \text{---} number of chocolates in ithi^{th} box, A[1],A[2],,A[N]A[1], A[2], \ldots, A[N] (1A[i]10131 \leq A[i] \leq 10^{13})

Output Format:

Print a single integer: the minimum number of consecutive boxes whose total number of chocolates is exactly KK.
If no such group exists, print 1-1.

Constraints:

(1N1051 \leq N \leq 10^5)
(1K10181 \leq K \leq 10^{18})
(1A[i]10131 \leq A[i] \leq 10^{13})

Examples:

Example 1:

Input:

7 8
1 3 2 1 4 1 3

Output:

3

Example 2:

Input:

4 3
1 1 1 10

Output:

3

Code

Loading Editor...