func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T &k) {     k = 0;     int flag = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) flag = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       k = k * 10 + c -  0 ;       c = getchar();     }     k *= flag;   }   const int N = 105;   int n, m, k, s, t, a[N];   char c[N];   long long f[N][N][N][2];   inline long long max3(long long a, long long b, long long c) {     return max(max(a, b), c);   }   int main() {     read(n);     cin >> c + 1;     for (int i = 1; i <= n; ++i) read(a[i]);     memset(f, -0x3f, sizeof(f));     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) a[j] = max(a[j], a[j - i] + a[i]);     for (int i = 1; i <= n; ++i) {       f[i][i][1][c[i] -  0 ] = 0;       f[i][i][0][0] = a[1];     }     for (int l = 1; l < n; ++l)       for (int i = 1; i + l <= n; ++i) {         int j = i + l;         for (int k = i; k < j; ++k) {           f[i][j][0][0] = max(f[i][j][0][0], f[i][k][0][0] + f[k + 1][j][0][0]);           f[i][j][1][0] = max3(f[i][j][1][0], f[i][k][1][0] + f[k + 1][j][0][0],                                f[i][k][0][0] + f[k + 1][j][1][0]);           f[i][j][1][1] = max3(f[i][j][1][1], f[i][k][1][1] + f[k + 1][j][0][0],                                f[i][k][0][0] + f[k + 1][j][1][1]);         }         for (int p = 2; p <= l + 1; ++p)           for (int k = i; k < j; ++k) {             f[i][j][p][0] =                 max(f[i][j][p][0], f[i][k][1][0] + f[k + 1][j][p - 1][0]);             f[i][j][p][1] =                 max(f[i][j][p][1], f[i][k][1][1] + f[k + 1][j][p - 1][1]);           }         for (int p = 1; p <= l + 1; ++p)           f[i][j][0][0] =               max3(f[i][j][0][0], f[i][j][p][0] + a[p], f[i][j][p][1] + a[p]);       }     cout << f[1][n][0][0] << endl;   }   