#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,b) for(int i=a;i<b;i++)
int main(){
int t;
cin>>t;
while(t–){
int n,k,ans=0,temp=0;
cin>>n>>k;
int a;
fori(i,0,n){
cin>>a;
if(a>k) {ans = -2; break;}
temp += a;
if(temp>k) {ans += 1; temp = a;}
}
cout<<ans+1<<endl;
}
}
Here is my code, i tried for an hour yesterday but couldnt get a submission, it shows WA everytime. I have searched for everything but i am found no test cases where this fail. do help and thanks!