Untitled

mail@pastecode.io avatar
unknown
c_cpp
4 months ago
210 B
1
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;
}
Leave a Comment