Language: C++

int N;
int t[110], v[110];
int lim[50010];
 
int dp[5][205];
 
int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) 
          cin >> t[i], t[i] *= 2;
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            cin >> v[i], v[i] *= 2;
            for (int j = ans; j < ans + t[i]; ++j) {
                lim[j] = v[i];
            }
            ans += t[i];
        }
        
        for (int i = 0; i < 5; ++i){
          for (int j = 0; j < 205; ++j){
            dp[i][j] = -1e27;
          }
        }
      
        dp[0][0] = 0;
        for (int i = 0; i < ans; ++i) {
          
            for (int j = 0; j < 205; ++j) {
                
                if (j + 1 <= min(lim[i], lim[i+1])) {
                  chmax(dp[(i+1)%2][j+1], dp[i%2][j] + j*2+1);
                }
              
                if (j <= min(lim[i], lim[i+1])){
                  chmax(dp[(i+1)%2][j], dp[i%2][j] + j*2);
                }
              
                if (j - 1 >= 0 && j - 1 <= min(lim[i], lim[i+1])){
                  chmax(dp[(i+1)%2][j-1], dp[i%2][j] + j*2-1);
                }
            }
            
            for (int j = 0; j < 205; ++j) dp[i%2][j] = -1e27;
          
        }
        
       printf("%.10lf\n",(double)dp[0][0]*0.125);
    }
}
 
 
 

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: 'cin' was not declared in this scope
    8 |     while (cin >> N) {
      |            ^~~
a.cc:22:24: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+27' to '-2147483648' [-Woverflow]
   22 |             dp[i][j] = -1e27;
      |                        ^~~~~
a.cc:31:30: error: 'min' was not declared in this scope; did you mean 'main'?
   31 |                 if (j + 1 <= min(lim[i], lim[i+1])) {
      |                              ^~~
      |                              main
a.cc:32:19: error: 'chmax' was not declared in this scope
   32 |                   chmax(dp[(i+1)%2][j+1], dp[i%2][j] + j*2+1);
      |                   ^~~~~
a.cc:35:26: error: 'min' was not declared in this scope; did you mean 'main'?
   35 |                 if (j <= min(lim[i], lim[i+1])){
      |                          ^~~
      |                          main
a.cc:36:19: error: 'chmax' was not declared in this scope
   36 |                   chmax(dp[(i+1)%2][j], dp[i%2][j] + j*2);
      |                   ^~~~~
a.cc:39:44: error: 'min' was not declared in this scope; did you mean 'main'?
   39 |                 if (j - 1 >= 0 && j - 1 <= min(lim[i], lim[i+1])){
      |                                            ^~~
      |                                            main
a.cc:40:19: error: 'chmax' was not declared in this scope
   40 |                   chmax(dp[(i+1)%2][j-1], dp[i%2][j] + j*2-1);
      |                   ^~~~~
a.cc:44:56: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+27' to '-2147483648' [-Woverflow]
   44 |             for (int j = 0; j < 205; ++j) dp[i%2][j] = -1e27;
      |                                                        ^~~~~
a.cc:48:8: error: 'printf' was not declared in this scope
   48 |        printf("%.10lf\n",(double)dp[0][0]*0.125);
      |        ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int N;