1 #include <iostream> 2 #include <numeric> 3 #include <algorithm> 4 int N, S; 5 int a[100001]; 6 int tc; 7 int main() 8 { 9 std::cin >> tc; 10 for(int i = 0; i < tc; ++i) 11 { 12 13 std::cin >> N >> S; 14 int minLen = N; 15 a[0] = 0; 16 for(int j = 0; j < N; ++j) 17 { 18 std::cin >> a[j+1]; 19 a[j+1] += a[j]; 20 } 21 if(a[N] < S ) 22 { 23 std::cout << 0 << std::endl; 24 continue; 25 } 26 27 for(int j = 1; a[j]+S <= a[N]; ++j) 28 { 29 int t = std::lower_bound(a+j, a+N+1, a[j]+S) - a; 30 minLen = std::min(minLen, t - j); 31 } 32 std::cout << minLen << std::endl; 33 } 34 35 return 0; 36 }