Untitled
unknown
c_cpp
a year ago
210 B
9
Indexable
int sol(int a[], int n, int k){
int sum=0, cnt=1;
for(int i=1; i<=n; ++i){
if(sum+a[i]>k) {
sum=0;
cnt++;
}
sum+=a[i];
}
return cnt;
}
Editor is loading...
Leave a Comment