[this](https://www.codechef.com/OCT20B/problems/CHEFEZQ) is the problem.↵
Here is what my solution was:↵
~~~~~↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
int main()↵
{↵
ll t;↵
cin>>t;↵
while(t--)↵
{↵
ll n,k;↵
cin>>n>>k;↵
ll queued=0;↵
bool gotit = false;↵
for(ll i=0; i<n; ++i)↵
{↵
ll x;↵
cin>>x;↵
queued= queued + (x-k);↵
if(queued<0)↵
{↵
cout<<i+1<<endl;↵
gotit = true;↵
break;↵
}↵
}↵
if(gotit)↵
continue;↵
↵
if(queued>0)↵
{↵
cout<<n+1+queued/k<<endl;↵
}↵
else cout<<n+1<<endl;↵
}↵
}↵
~~~~~↵
and as expected, it was giving correct results in test cases except for one, which was giving runtime error, the error which comes by the division of 0.↵
(and to be sure, I even tried running infinite loop if k==0, and then it showed TLE at the same test case.)↵
Now the thing is it is given k>0 and when I tried a little different technique, it was accepted.↵
So what is the problem here?↵
Here is what my solution was:↵
~~~~~↵
#include<bits/stdc++.h>↵
#define ll long long↵
using namespace std;↵
int main()↵
{↵
ll t;↵
cin>>t;↵
while(t--)↵
{↵
ll n,k;↵
cin>>n>>k;↵
ll queued=0;↵
bool gotit = false;↵
for(ll i=0; i<n; ++i)↵
{↵
ll x;↵
cin>>x;↵
queued= queued + (x-k);↵
if(queued<0)↵
{↵
cout<<i+1<<endl;↵
gotit = true;↵
break;↵
}↵
}↵
if(gotit)↵
continue;↵
↵
if(queued>0)↵
{↵
cout<<n+1+queued/k<<endl;↵
}↵
else cout<<n+1<<endl;↵
}↵
}↵
~~~~~↵
and as expected, it was giving correct results in test cases except for one, which was giving runtime error, the error which comes by the division of 0.↵
(and to be sure, I even tried running infinite loop if k==0, and then it showed TLE at the same test case.)↵
Now the thing is it is given k>0 and when I tried a little different technique, it was accepted.↵
So what is the problem here?↵