Chef and Easy Queries CodeChef Solution

Chef and Easy Queries CodeChef Solution

In this post, the Chef and Easy Queries CodeChef Solution is given. Question details : October Challenge 2020 Division 2 > Chef and Easy Queries CodeChef.

Chef and Easy Queries CodeChef Solution

#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
#define ll long long
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
int main()
{
Fastio;
ll t; cin>>t;
while(t--)
{
ll n,k,i;
cin>>n>>k;
ll a[n];
for(ll j=0;j<n;j++)
cin>>a[j]
ll l=0;
ll d=0;
for(i=0;i<n;i++)
{
l+=a[i];
l-=k;
if(l<0)
{
d=i+1;
break;
}            
}
if(l==0)
d=n+1;
else if(l>0)
{
d=n+l/k;
d++;
}
cout<<d<<endl;
}
}


The solution of the above program is contributed by Vishal Vaibhab (IIT BHU). If you like TheCode11, then do follow us on Facebook, Twitter and Instagram.

Post a Comment

Previous Post Next Post

Contact Form