func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 110;   const int INF = 1e9;   int _w;   int n, a[MAXN], b[MAXN];   namespace MCMF {   const int MAXV = 1000000;   const int MAXE = 1000000;   struct Edge {     int u, v, c, f, w;     Edge() {}     Edge(int u, int v, int c, int f, int w) : u(u), v(v), c(c), f(f), w(w) {}   };   int n, m, s, t;   int head[MAXV], nxt[MAXE << 1];   Edge edge[MAXE << 1];   void init(int nn) {     n = nn, m = 0;     for (int i = 1; i <= n; ++i) head[i] = -1;   }   void adde(int u, int v, int c, int w) {     edge[m] = Edge(u, v, c, 0, w);     nxt[m] = head[u], head[u] = m++;     edge[m] = Edge(v, u, 0, 0, -w);     nxt[m] = head[v], head[v] = m++;   }   queue<int> q;   int inq[MAXV], dis[MAXV], res[MAXV], pre[MAXV];   bool spfa() {     for (int i = 1; i <= n; ++i) inq[i] = 0, dis[i] = -INF;     q.push(s), inq[s] = 1, dis[s] = 0, res[s] = INF;     while (!q.empty()) {       int u = q.front();       q.pop();       inq[u] = 0;       for (int i = head[u]; ~i; i = nxt[i]) {         Edge &e = edge[i];         if (e.c > e.f && dis[e.v] < dis[u] + e.w) {           dis[e.v] = dis[u] + e.w;           res[e.v] = min(res[u], e.c - e.f);           pre[e.v] = i;           if (!inq[e.v]) {             inq[e.v] = 1;             q.push(e.v);           }         }       }     }     return dis[t] != -INF;   }   void augment() {     int u = t, f = res[t];     while (u != s) {       int i = pre[u];       edge[i].f += f;       edge[i ^ 1].f -= f;       u = edge[i].u;     }   }   int solve(int ss, int tt) {     s = ss, t = tt;     int ans = 0, flow = 0;     while (spfa()) {       augment();       ans += dis[t] * res[t];       flow += res[t];     }     return ans;   }   }  // namespace MCMF   int id1[27], id2[27][MAXN], id3[MAXN], s, t, nid;   void solve() {     for (int i = 1; i <= 26; ++i) id1[i] = ++nid;     for (int i = 1; i <= 26; ++i)       for (int j = 1; j <= n / 2; ++j) id2[i][j] = id2[i][n - j + 1] = ++nid;     for (int i = 1; i <= n; ++i) id3[i] = ++nid;     s = ++nid, t = ++nid;     MCMF::init(nid);     for (int i = 1; i <= n; ++i) MCMF::adde(s, id1[a[i]], 1, 0);     for (int i = 1; i <= 26; ++i)       for (int j = 1; j <= n / 2; ++j) MCMF::adde(id1[i], id2[i][j], 1, 0);     for (int i = 1; i <= 26; ++i)       for (int j = 1; j <= n; ++j)         MCMF::adde(id2[i][j], id3[j], 1, a[j] == i ? b[j] : 0);     for (int i = 1; i <= n; ++i) MCMF::adde(id3[i], t, 1, 0);     printf( %d n , MCMF::solve(s, t));   }   int main() {     _w = scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       char c;       _w = scanf(  %c , &c);       a[i] = c -  a  + 1;     }     for (int i = 1; i <= n; ++i) _w = scanf( %d , b + i);     solve();     return 0;   }   