func_code_string: #include <bits/stdc++.h>   const long long oo = 0x7f7f7f7f7f7f7f7f;   using namespace std;   const long long maxn = 1e6 + 999;   long long n, m, k, visa[maxn], visb[maxn], b[maxn], tota, totb, totc, totd;   struct goods {     long long val, id;     friend bool operator<(goods x, goods y) { return x.val < y.val; }   } a[maxn], A[maxn], B[maxn], C[maxn];   long long tot, cnt[maxn << 2], ls[maxn << 2], rs[maxn << 2], root;   long long sumv[maxn << 2];   void insert(long long pos, long long val, long long l, long long r,               long long &rt) {     if (val == 0 || pos == 0) return;     if (!rt) rt = ++tot;     if (val > 0)       sumv[rt] += val, cnt[rt]++;     else       sumv[rt] += val, cnt[rt]--;     if (l == r) {       return;     }     long long mid = l + r >> 1;     if (pos <= mid)       insert(pos, val, l, mid, ls[rt]);     else       insert(pos, val, mid + 1, r, rs[rt]);   }   long long query(long long k, long long l, long long r, long long rt) {     if (!k) return 0;     if (l == r) {       return min(k, cnt[rt]) * b[l];     }     long long cntt = cnt[ls[rt]];     long long mid = l + r >> 1;     if (k <= cntt)       return query(k, l, mid, ls[rt]);     else       return sumv[ls[rt]] + query(k - cntt, mid + 1, r, rs[rt]);   }   signed main() {     scanf( %lld%lld%lld , &n, &m, &k);     for (long long i = 1; i <= n; i++)       scanf( %lld , &a[i].val), b[i] = a[i].val, a[i].id = i;     sort(b + 1, b + 1 + n);     for (long long i = 1; i <= n; i++)       a[i].val = lower_bound(b + 1, b + 1 + n, a[i].val) - b;     long long x;     scanf( %lld , &x);     for (long long i = 1; i <= x; i++) {       long long p;       scanf( %lld , &p);       visa[p] = 1;     }     scanf( %d , &x);     for (long long i = 1; i <= x; i++) {       long long p;       scanf( %d , &p);       visb[p] = 1;     }     for (long long i = 1; i <= n; i++) {       if (visa[i] && visb[i])         A[++tota] = a[i];       else if (visa[i] && !visb[i])         B[++totb] = a[i];       else if (visb[i] && !visa[i])         C[++totc] = a[i];       insert(a[i].val, b[a[i].val], 1, n, root), totd++;     }     long long ans = oo, tmp = 0;     long long now1 = min(k, min(totb, totc));     sort(A + 1, A + 1 + tota);     sort(B + 1, B + 1 + totb);     sort(C + 1, C + 1 + totc);     for (long long i = 1; i <= now1; i++)       tmp += b[B[i].val] + b[C[i].val],           insert(C[i].val, -b[C[i].val], 1, n, root),           insert(B[i].val, -b[B[i].val], 1, n, root), totd -= 2;     long long ls = 0;     for (long long r = 0; r <= tota; r++) {       if (r + now1 == k && m - (r + now1 * 2) >= 0 &&           m - (r + now1 * 2) <= totd) {         ans = min(ans, tmp + query(m - (r + now1 * 2), 1, n, root));       }       tmp += b[A[r + 1].val];       insert(A[r + 1].val, -b[A[r + 1].val], 1, n, root), totd--;       if (r + 1 + now1 > k && now1 > 0) {         tmp -= b[B[now1].val] + b[C[now1].val],             insert(C[now1].val, b[C[now1].val], 1, n, root),             insert(B[now1].val, b[B[now1].val], 1, n, root), totd += 2;         now1--;       }     }     if (ans == oo) ans = -1;     cout << ans;   }   