func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const long long inf = 1e16;   const long long ninf = LLONG_MIN;   const double eps = 1e-12;   const long long N = 1000005;   const double PI = 3.14159265358979323846;   const long long LOGN = 19;   long long n, m;   long long s[N], t[N];   char a[N];   long long dp[(1 << 21)];   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> s[i];     cin >> m;     sort(s, s + n);     reverse(s, s + n);     for (int i = 0; i < m; i++) cin >> a[i] >> t[i];     for (long long mask = (1 << m) - 1; mask >= 0; mask--) {       long long done = __builtin_popcount(mask);       if (done == m) {         dp[mask] = 0;         continue;       }       if (a[done] ==  p ) {         for (int j = 0; j < m; j++) {           if ((mask & (1 << j)) == 0) {             dp[mask] = (t[done] == 1 ? s[j] : -s[j]) + dp[mask | (1 << j)];             break;           }         }       } else {         if (t[done] == 1) {           dp[mask] = -inf;           for (int j = 0; j < m; j++) {             dp[mask] = max(dp[mask], dp[mask | (1 << j)]);           }         } else {           dp[mask] = inf;           for (int j = 0; j < m; j++) {             dp[mask] = min(dp[mask], dp[mask | (1 << j)]);           }         }       }     }     cout << dp[0] <<   n ;     return 0;   }   