func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   int n, m, k;   int t, x;   int c[200010];   int f1[200010];   int f2[200010];   vector<int> w, a, b;   vector<int> d;   vector<ll> ww, aa, bb, dd;   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < n; i++) cin >> c[i];     cin >> t;     for (int i = 0; i < t; i++) {       cin >> x;       f1[x - 1] = 1;     }     cin >> t;     for (int i = 0; i < t; i++) {       cin >> x;       f2[x - 1] = 1;     }     for (int i = 0; i < n; i++) {       if (f1[i] && f2[i])         w.push_back(c[i]);       else if (f1[i])         a.push_back(c[i]);       else if (f2[i])         b.push_back(c[i]);       else         d.push_back(c[i]);     }     sort(w.begin(), w.end());     sort(a.begin(), a.end());     sort(b.begin(), b.end());     sort(d.begin(), d.end());     ww.push_back(0);     aa.push_back(0);     bb.push_back(0);     dd.push_back(0);     for (int i = 0; i < w.size(); i++) ww.push_back(ww.back() + w[i]);     for (int i = 0; i < a.size(); i++) aa.push_back(aa.back() + a[i]);     for (int i = 0; i < b.size(); i++) bb.push_back(bb.back() + b[i]);     for (int i = 0; i < d.size(); i++) dd.push_back(dd.back() + d[i]);     ll ans = 1e18 + 1;     for (int i = 0; i <= w.size(); i++) {       ll cost = ww[i];       int need = max(0, k - i);       if (need > a.size() || need > b.size() || i + need * 2 > m) continue;       cost += aa[need];       cost += bb[need];       int re = m - i - 2 * need;       if (a.size() - need + b.size() - need + d.size() < re) continue;       if (re > 0) {         int l = 0;         int r = 1e9 + 1;         while (l < r) {           int mid = (l + r) / 2;           int cnt = 0;           int h = upper_bound(a.begin(), a.end(), mid) - a.begin();           cnt += max(0, h - need);           h = upper_bound(b.begin(), b.end(), mid) - b.begin();           cnt += max(0, h - need);           h = upper_bound(d.begin(), d.end(), mid) - d.begin();           cnt += max(0, h);           if (cnt >= re)             r = mid;           else             l = mid + 1;         }         {           int mid = l;           int cnt = 0;           int h = upper_bound(a.begin(), a.end(), mid) - a.begin();           cnt += max(0, h - need);           if (h > need) cost += aa[h] - aa[need];           h = upper_bound(b.begin(), b.end(), mid) - b.begin();           cnt += max(0, h - need);           if (h > need) cost += bb[h] - bb[need];           h = upper_bound(d.begin(), d.end(), mid) - d.begin();           cnt += max(0, h);           cost += dd[h];           if (cnt > re) cost -= mid * (cnt - re);         }       }       ans = min(ans, cost);     }     if (ans > 1e17) ans = -1;     cout << ans << endl;     return 0;   }   