I wrote this code for the Chef Easy Queries Problem in CPP (Contest Page  CodeChef). It is satisfying the sample cases as well as all the test cases except one (the first test case). I have tried nearly everything, but that case just does not budge.
My algorithm 

Input the values of T,n,k.

Then run a loop T times. Inside this run another loop n times. In the inside loop, ask for Query (Q) and increment the day (day) by 1. Add it to the leftover queries from days before (left). From this quantity subtract (k). If it becomes negative, then break the loop and output the value of day we have.

If the whole loop runs without (left) becoming negative, it means no free days till now. So, we increment the (day) variable by the quotient of (left) upon (k) plus 1.
This is our answer if (left) does not become negative.
I can’t find anything wrong with this, yet I am not able to solve the first test case of this problem. Any help would be appreciated.
#include
using namespace std;int main() {
long long int T;
cin>>T;
for(long long int i=0;i<T;i++){
long long int n,k,left=0,Q,day=0; cin>>n>>k; for(long long int j=0;j<n;j++){ day++; cin>>Q; left+=Q; left=k; if(left<0){ cout<<day<<endl; break; } } if(left>=0){ day+=(left/k)+1; cout<<day<<endl; }
}
return 0;
}