func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5000 + 10;   int n, a[N], dp[N][N][2];   int calc(int i, int rem, bool isLess) {     if (rem == 0) return 0;     if (i >= n) return 2e9;     int &ret = dp[i][rem][isLess];     if (ret != -1) return ret;     ret = 2e9;     if (isLess) {       if (i != n - 1) {         int h = a[i + 1];         int extra = max(h - a[i] + 1, 0);         h -= extra;         ret = min(ret, extra + calc(i + 2, rem - 1, h < a[i + 2]));         if (i != n - 2) {           int h = a[i + 1];           int extra = max(h - a[i + 2] + 1, 0);           h -= extra;           ret = min(ret, extra + calc(i + 2, rem - (h < a[i]), h < a[i + 2]));         }         ret = min(ret, calc(i + 1, rem, a[i] < a[i + 1]));         if (a[i] >= a[i + 1])           ret = min(ret, (a[i] - a[i + 1] + 1) + calc(i + 1, rem, true));       } else         ret = min(ret, calc(i + 1, rem - 1, false));     } else {       if (i != n - 1) {         ret = min(ret, calc(i + 1, rem, a[i] < a[i + 1]));         if (a[i] >= a[i + 1])           ret = min(ret, (a[i] - a[i + 1] + 1) + calc(i + 1, rem, true));       }     }     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     memset(dp, -1, sizeof dp);     int k = (n + 1) / 2;     for (int i = 1; i <= k; ++i) printf( %d  , calc(0, i, true));     puts(  );     return 0;   }   