func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK: 1024000000,1024000000 )   using namespace std;   inline int getint() {     int _x = 0;     char _tc = getchar();     while (_tc <  0  || _tc >  9 ) _tc = getchar();     while (_tc >=  0  && _tc <=  9 ) _x *= 10, _x += (_tc -  0 ), _tc = getchar();     return _x;   }   const int N = 1010, M = 1e5 + 15, INF = 1e7;   bool vis[N];   int dis[N];   struct Edge {     int u, v, c, w;     int nxt;     Edge() {}     Edge(int t2, int t3, int t4, int t5, int t6)         : u(t2), v(t3), c(t4), w(t5), nxt(t6) {}   };   Edge e[M];   int h[N], ect;   int mom[N], id[N];   int n, m, A[N], D[N], X[N], ca, cd;   char s[10];   int S, T;   void init() {     memset(vis, false, sizeof(vis));     ect = 0;     memset(h, -1, sizeof(h));     ca = cd = 0;   }   void _add(int u, int v, int c, int w) {     e[ect] = Edge(u, v, c, w, h[u]);     h[u] = ect++;     e[ect] = Edge(v, u, 0, -w, h[v]);     h[v] = ect++;   }   int spfa() {     queue<int> Q;     for (int i = S + 1; i <= T; i++) dis[i] = 10 * INF;     Q.push(S);     vis[S] = true;     while (!Q.empty()) {       int u = Q.front();       Q.pop();       vis[u] = false;       for (int i = h[u]; i + 1; i = e[i].nxt) {         int v = e[i].v;         if (e[i].c && dis[v] > dis[u] + e[i].w) {           dis[v] = dis[u] + e[i].w;           if (!vis[v]) vis[v] = true, Q.push(v);           id[v] = i;         }       }     }     return dis[T];   }   void aug() {     int p = T;     while (p != S) {       e[id[p]].c -= 1;       e[id[p] ^ 1].c += 1;       p = e[id[p] ^ 1].v;     }   }   int MFMC() {     int ret = 0, d, tmp = 0;     for (int i = 1; i <= n; i++) {       d = spfa();       if (d == 10 * INF) return -ret;       tmp += d, ret = min(ret, tmp), aug();     }     for (int i = n + 1; i <= m; i++) {       d = spfa();       if (d == 10 * INF) return -ret;       tmp += d - 2 * INF, ret = min(ret, tmp), aug();     }     return -ret;   }   int main() {     init();     scanf( %d%d , &n, &m);     S = 0, T = n + m + 1;     dis[S] = 0;     for (int i = 1, x; i <= n; i++) {       scanf( %s %d , s, &x);       if (s[0] ==  A )         A[++ca] = x;       else         D[++cd] = x;     }     for (int i = 1; i <= n; i++) _add(i + m, T, 1, 0);     for (int i = 1; i <= m; i++) {       scanf( %d , &X[i]);       _add(S, i, 1, 0);       _add(i, T, 1, 2 * INF - X[i]);       for (int j = 1; j <= ca; j++)         if (X[i] >= A[j]) _add(i, j + m, 1, A[j] - X[i]);       for (int j = 1; j <= cd; j++)         if (X[i] > D[j]) _add(i, j + m + ca, 1, 0);     }     printf( %d n , MFMC());     return 0;   }   