func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> a[4];   vector<long long> sum[4];   int hasha[200050], hashb[200050];   int c[200050];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m, k, t;     cin >> n >> m >> k;     memset(hasha, 0, sizeof(hasha));     memset(hashb, 0, sizeof(hashb));     for (int i = 1; i <= n; i++) cin >> c[i];     cin >> t;     for (int i = 0; i < t; i++) {       int x;       cin >> x;       hasha[x] = 1;     }     cin >> t;     for (int i = 0; i < t; i++) {       int x;       cin >> x;       hashb[x] = 1;     }     for (int i = 1; i <= n; i++) {       if (hasha[i] && hashb[i])         a[3].push_back(c[i]);       else if (!hasha[i] && hashb[i])         a[2].push_back(c[i]);       else if (hasha[i] && !hashb[i])         a[1].push_back(c[i]);       else         a[0].push_back(c[i]);     }     for (int i = 0; i < 4; i++) sort(a[i].begin(), a[i].end());     for (int i = 0; i < 4; i++) sum[i].push_back(0);     for (int i = 0; i < 4; i++) {       for (int j = 0; j < a[i].size(); j++)         sum[i].push_back(sum[i].back() + a[i][j]);     }     long long ans = 1e18 + 1;     for (int i = 0; i <= a[3].size(); i++) {       long long cost = sum[3][i];       int need = max(0, k - i);       if (need > a[1].size() || need > a[2].size() || i + need * 2 > m) continue;       cost += sum[1][need], cost += sum[2][need];       int left = m - i - 2 * need;       if (a[1].size() - need + a[2].size() - need + a[0].size() < left) continue;       if (left > 0) {         int l = 0, r = 1e9;         while (l < r) {           int mid = (l + r) / 2;           int cnt = 0;           int h = upper_bound(a[0].begin(), a[0].end(), mid) - a[0].begin();           cnt += max(0, h);           h = upper_bound(a[1].begin(), a[1].end(), mid) - a[1].begin();           cnt += max(0, h - need);           h = upper_bound(a[2].begin(), a[2].end(), mid) - a[2].begin();           cnt += max(0, h - need);           if (cnt >= left)             r = mid;           else             l = mid + 1;         }         int mid = l, cnt = 0;         int h = upper_bound(a[0].begin(), a[0].end(), mid) - a[0].begin();         cnt += max(0, h);         cost += sum[0][h];         h = upper_bound(a[1].begin(), a[1].end(), mid) - a[1].begin();         cnt += max(0, h - need);         if (h > need) cost += sum[1][h] - sum[1][need];         h = upper_bound(a[2].begin(), a[2].end(), mid) - a[2].begin();         cnt += max(0, h - need);         if (h > need) cost += sum[2][h] - sum[2][need];         if (cnt > left) cost -= mid * (cnt - left);       }       ans = min(ans, cost);     }     if (ans > 1e17) ans = -1;     cout << ans << endl;     return 0;   }   