func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   struct AA {     int p, s;   } c[110];   int st[110];   bool cmp1(AA a, AA b) {     if (a.p == b.p) return a.s < b.s;     return a.p < b.p;   }   bool vis[110];   int work1() {     int ret = 0;     sort(c, c + n, cmp1);     sort(st, st + m);     for (int i = 0; i < n; i++) {       if (i == m) break;       if (c[i].p == 1) break;       if (c[i].s > st[m - 1 - i]) break;       ret += st[m - 1 - i] - c[i].s;     }     return ret;   }   int work2() {     int ret = 0;     sort(c, c + n, cmp1);     sort(st, st + m);     memset(vis, 0, sizeof(vis));     for (int i = 0; i < n; i++)       if (c[i].p == 1) {         bool fg = true;         for (int j = 0; j < m; j++)           if (!vis[j] && st[j] > c[i].s) {             vis[j] = true;             fg = false;             break;           }         if (fg) return 0;       }     for (int i = 0; i < n; i++)       if (c[i].p == 0) {         bool fg = true;         for (int j = 0; j < m; j++)           if (!vis[j] && st[j] >= c[i].s) {             vis[j] = true;             ret += st[j] - c[i].s;             fg = false;             break;           }         if (fg) return 0;       }     for (int j = 0; j < m; j++)       if (!vis[j]) ret += st[j];     return ret;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       char s[10];       scanf( %s , s);       if (s[0] ==  A )         c[i].p = 0;       else         c[i].p = 1;       scanf( %d , &c[i].s);     }     for (int i = 0; i < m; i++) scanf( %d , &st[i]);     cout << max(work1(), work2());   }   