func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 110;   long long dp[N][N][N];   char s[N];   int a[N];   long long f[N];   void update(long long &x, long long y) {     if (y == -1) return;     if (x == -1 || x < y) x = y;   }   bool vis[N][N][N];   long long dfs(int l, int r, int p) {     if (l > r) return a[p];     if (vis[l][r][p]) return dp[l][r][p];     vis[l][r][p] = true;     if (l == r) {       return dp[l][r][p] = f[p + 1];     }     dp[l][r][p] = dfs(l, r - 1, 0) + f[p + 1];     for (int k = l; k < r; k++)       if (s[k] == s[r]) {         update(dp[l][r][p], dfs(l, k, p + 1) + dfs(k + 1, r - 1, 0));       }     return dp[l][r][p];   }   int main() {     int n;     cin >> n;     cin >> (s + 1);     for (int i = 1; i <= n; i++) cin >> a[i];     f[0] = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= i; j++) f[i] = max(f[i], f[i - j] + a[j]);     memset(dp, -1, sizeof(dp));     cout << dfs(1, n, 0) << endl;     return 0;   }   