Skip to content

Commit 4a77b62

Browse files
Create CHEFEZQ.cpp
Solution to chefczq from long challenge
1 parent 67fa995 commit 4a77b62

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Codechef solutions/CHEFEZQ.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <iostream>
2+
#include<vector>
3+
using namespace std;
4+
5+
int main() {
6+
long int t,n,i,pos;
7+
long long int k,x;
8+
cin>>t;
9+
while(t--){
10+
x=0;pos=-1;
11+
cin>>n>>k;
12+
vector<long long int> Q(n);
13+
for(i=0;i<n;i++)
14+
{
15+
cin>>Q[i];
16+
x+=Q[i];
17+
if(x<k && pos==-1)pos=i+1;
18+
else x-=k;
19+
}
20+
if(pos==-1)cout<<n+(x/k)+1<<"\n";
21+
else cout<<pos<<"\n";
22+
}
23+
return 0;
24+
}

0 commit comments

Comments
 (0)