-
Notifications
You must be signed in to change notification settings - Fork 6
/
codechef_query_08.cpp
57 lines (53 loc) · 1.1 KB
/
codechef_query_08.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
// #include<vector>
#include <bits/stdc++.h>
using namespace std;
int main(){
unsigned long t;
cin>>t;
//Akash here
for(unsigned long int i=0;i<t;i++){
unsigned long int n,j;
unsigned long int k,qel,val=0;
vector<unsigned long int> Q;
cin>>n>>k;
unsigned long int pend=0;
for( j=0;j<n;j++){
cin>>qel;
Q.push_back(qel);
}
//End
for( j=0;j<n;j++){
// cin>>qel;
Q[j]+=pend;
if(Q[j]>=k){
pend=Q[j]-k;
}
else{
cout<<j+1<<endl;
val=1;
break;
}
}
if(val==0){
if(pend>k){
if(pend%k==0){
cout<<j+(pend/k)+1<<endl;
}
else{
cout<<j+(pend/k)+1<<endl;
}
}
else
if(pend==k){
cout<<j+1<<endl;
}
else{
cout<<j<<endl;
}
}
else{
}
}
return 0;
}