#pragma GCC optimize("Ofast") #include #define int long long using namespace std; void fileio(const string &s) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int INF=4e18; inline int read() { int x=0; bool flag=1; char c=getchar(); while(c<'0'||c>'9') { if(c=='-') flag=0; c=getchar(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar(); } return (flag?x:~(x-1)); } int t,minn,maxx,n,k,sum,cnt,a[100001]; void solve() { n=read(); k=read(); minn=0; maxx=0; cnt=0; sum=0; for(int i=1;i<=n;i++) { a[i]=read(); sum+=a[i]; minn=min(minn,sum); maxx=max(maxx,sum); } for(int i=1;i<=n;i++) { cnt=max(0ll,cnt+a[i]); if(cnt>=k) { puts("1"); return ; } } for(int i=1;i<=n;i++) { cnt=max(0ll,cnt+a[i]); if(cnt>=k) { puts("2"); return ; } } if(cnt+minn<=0) { puts("-1"); return ; } if(sum<0) { puts("-1"); return ; } cout<<(k-maxx-cnt+sum-1)/sum+3<