func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 105;   long long f[MAXN][MAXN][MAXN];   int a[MAXN];   string s;   int n;   long long solve(int l, int r, int pf) {     if (l >= r) return 0;     if (r - l == 1) return a[pf];     long long &cur = f[l][r][pf];     if (cur > 0) return cur;     cur = max(cur, solve(l + 1, r, 1) + a[pf]);     for (int i = l + 1; i < r; i++)       if (s[l] == s[i]) cur = max(cur, solve(l + 1, i, 1) + solve(i, r, pf + 1));     return cur;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> s;     for (int i = 1; i <= n; i++) cin >> a[i];     cout << solve(0, n, 1) << endl;     return 0;   }   