Minimum SubArray

All submissions for this problem are available.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
You are given a sequence of n integers a_{1}, a_{2}, ..., a_{n} and an integer d.
Find the length of the shortest nonempty contiguous subsequence with sum of elements at least d. Formally, you should find the smallest positive integer k with the following property: there is an integer s (1 ≤ s ≤ Nk+1) such that a_{s} + a_{s+1} + ... + a_{s+k1} ≥ d.
Input
 The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
 The first line of each test case contains two spaceseparated integers n and d.
 The second line contains n spaceseparated integers a_{1}, a_{2}, ..., a_{n}.
Output
For each test case, print a single line containing one integer — the length of the shortest contiguous subsequence with sum of elements ≥ d. If there is no such subsequence, print 1 instead.
Constraints
 1 ≤ T ≤ 10^{5}
 1 ≤ n ≤ 10^{5}
 10^{9} ≤ d ≤ 10^{9}
 10^{4} ≤ a_{i} ≤ 10^{4}
 1 ≤ sum of n over all test cases ≤ 2 · 10^{5}
Example
Input: 2 5 5 1 2 3 1 5 5 1 1 2 3 1 5 Output: 2 1
Author:  chemthan 
Tester:  kingofnumbers 
Editorial  https://discuss.codechef.com/problems/MINSUBAR 
Tags  binarysearch, chemthan, chemthan, cook89, easymedium, likecs, prefixsum 
Date Added:  23102017 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 