func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = (1LL << 30) - 1;   const long long int LINF = (1LL << 62) - 1;   const int NMAX = (1e5) + 5;   int N, M;   int pile[NMAX];   bool check(long long int time) {     int i, k;     long long int curr;     int P[NMAX];     memcpy(P, pile, sizeof(pile));     for (i = N, k = 1; k <= M; k++) {       while (P[i] == 0 && i >= 1) i--;       if (i == 0) return 1;       curr = i;       while (curr < time) {         if (curr + P[i] <= time) {           curr += P[i];           P[i] = 0;         } else {           P[i] -= time - curr;           curr = time;         }         while (P[i] == 0 && i >= 1) i--;         if (i == 0) return 1;       }     }     return 0;   }   int main() {     int i;     long long int lo = 0, hi = 0, mi;     long long int sol;     cin.sync_with_stdio(false);     scanf( %d%d , &N, &M);     hi += N;     for (i = 1; i <= N; i++) {       scanf( %d , &pile[i]);       hi += pile[i];     }     sol = hi;     while (lo <= hi) {       mi = (lo + hi) / 2;       if (check(mi)) {         sol = min(sol, mi);         hi = mi - 1;       } else         lo = mi + 1;     }     printf( %lld n , sol);     return 0;   }   