func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1100;   struct VIS {     int c, p;     int id;     bool operator<(const VIS& t) const {       if (p == t.p) return c < t.c;       return p > t.p;     }   } A[MAXN];   struct TAB {     int c;     int id;     bool operator<(const int t) const { return c < t; }     bool operator<(const TAB& t) const { return c < t.c; }   } Tb[MAXN];   bool vis[MAXN];   struct PAIR {     int v;     int t;     bool operator<(const PAIR& t) const { return v < t.v; }   } pai[MAXN];   int len;   int sum;   int main() {     int N, K;     while (scanf( %d , &(N)) != EOF) {       for (int i = (1); i < (N + 1); ++i) {         scanf( %d%d , &A[i].c, &A[i].p);         A[i].id = i;       }       sort(A + 1, A + N + 1);       scanf( %d , &(K));       for (int i = (1); i < (K + 1); ++i) {         scanf( %d , &(Tb[i].c));         Tb[i].id = i;       }       sort(Tb + 1, Tb + K + 1);       len = 0;       sum = 0;       memset(vis, 0, sizeof(vis));       for (int i = (1); i < (N + 1); ++i) {         int p = lower_bound(Tb + 1, Tb + K + 1, A[i].c) - Tb;         while (p <= K && vis[p]) ++p;         if (p > K) continue;         vis[p] = 1;         sum += A[i].p;         pai[len].v = A[i].id;         pai[len].t = Tb[p].id;         ++len;       }       sort(pai, pai + len);       printf( %d %d n , len, sum);       for (int k = (0); k < (len); ++k) {         printf( %d %d n , pai[k].v, pai[k].t);       }     }     return 0;   }   