# POJ3061 尺取法

ｎ个数字，求最短的连续的数字长度，满足和>=s

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
public static void main(String[] args) {
new POJ3061().solve();
}
}

class POJ3061 {

PrintWriter out = new PrintWriter(System.out);
final int N = 100008;
int[] a = new int[N];

void solve() {
int t = in.nextInt();
while (t-- > 0) {
int n = in.nextInt();
int s = in.nextInt();
for (int i = 0; i < n; i++)
a[i] = in.nextInt();

int start = 0, end = 0, sum = 0, res = n + 1;
for (;;) {
while (end < n && sum < s) {
sum += a[end++];
}
if (sum < s)
break;
res = Math.min(res, end - start);
sum -= a[start++];
}
out.println(res == n + 1 ? 0 : res);
}
out.flush();
}
}

public StringTokenizer tokenizer;

public InputReader(InputStream stream) {
tokenizer = new StringTokenizer("");
}

private void eat(String s) {
tokenizer = new StringTokenizer(s);
}

public String nextLine() {
try {
} catch (Exception e) {
return null;
}
}

public boolean hasNext() {
while (!tokenizer.hasMoreTokens()) {
String s = nextLine();
if (s == null)
return false;
eat(s);
}
return true;
}

public String next() {
hasNext();
}

public int nextInt() {
return Integer.parseInt(next());
}

public long nextLong() {
return Long.parseLong(next());
}

public double nextDouble() {
return Double.parseDouble(next());
}

public BigInteger nextBigInteger() {
return new BigInteger(next());
}

}


10-14 677

04-07 9

07-24 106

01-23 35

05-29 286

04-19 198

04-24 140

03-06 206

04-05 6

02-28 7