Mini subarray

0

0 votes
Problem

Given an array of Integers and a value s.

Can you find a subarray of which the sum of all the elements is greater than the given sum (s)? That is (ai + ai+1 ......ak ) >= s.

Out of all the subarrays of which the sum >= s, find the one having minimum length.


INPUT:

The first line contains one integer t(1 ≤ t ≤ 20) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers n(1 ≤ n ≤ 105) and s (1 ≤ s ≤ 109 )  — the size of the array and given sum.

The second line contains n integers ai  (1 ≤ a≤ 104)— the value of the ith element.

30% test cases -- (1 ≤ n ≤ 103 )


OUTPUT:

For each test case, print the Minimum length of the subarray, if it doesn't exist print 0.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

test case 1:  subarray from index 5 to index 6

second test: not possible to obtain the given sum.

Editor Image

?