func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( -O3 )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   long long n, m, k, i, ost, x, y, ans, a[200010], f[200010], ost1, sum1;   vector<pair<long long, long long>> v3, v1, v2;   pair<long long, long long> sum;   multiset<long long> st, st1;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (i = 1; i <= n; i++) cin >> a[i];     cin >> x;     for (i = 0; i < x; i++) {       cin >> y;       f[y]++;     }     cin >> x;     for (i = 0; i < x; i++) {       cin >> y;       f[y] += 2;     }     for (i = 1; i <= n; i++) {       if (f[i] == 1) v1.push_back(make_pair(a[i], i));       if (f[i] == 2) v2.push_back(make_pair(a[i], i));       if (f[i] == 3) v3.push_back(make_pair(a[i], i));     }     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     sort(v3.begin(), v3.end());     x = v3.size();     x = min(x, k);     y = k - x;     if (min((long long)v1.size(), (long long)v2.size()) < y or m < x + y * 2) {       cout << -1 << endl;       return 0;     }     for (i = 0; i < x; i++) {       sum.first += v3[i].first;       a[v3[i].second] = 1e18;     }     for (i = 0; i < y; i++) {       sum.first += v1[i].first;       a[v1[i].second] = 1e18;       sum.first += v2[i].first;       a[v2[i].second] = 1e18;     }     sort(a + 1, a + n + 1);     ost = m - x - 2 * y;     for (i = 1; i <= n; i++) {       if (i <= ost)         st1.insert(a[i]), sum.second += a[i];       else         st.insert(a[i]);     }     ans = sum.first + sum.second;     while (x) {       if (min((long long)v1.size(), (long long)v2.size()) <= y or y > k or           x + (y + 1) * 2 - 1 > m)         break;       if (ost > 0) ost--;       x--;       sum.first -= v3[x].first;       sum.first += v1[y].first + v2[y].first;       st.insert(v3[x].first);       auto it = st.find(v1[y].first);       if (it != st.end())         st.erase(it);       else {         it = st1.find(v1[y].first);         st1.erase(it);         sum.second -= v1[y].first;       }       it = st.find(v2[y].first);       if (it != st.end())         st.erase(it);       else {         it = st1.find(v2[y].first);         st1.erase(it);         sum.second -= v2[y].first;       }       y++;       ost1 = st1.size(), sum1 = sum.second;       it = st1.end();       while (ost1 > ost) {         ost1--;         it--;         sum1 -= *it;       }       for (auto it = st.begin(); it != st.end(); it++) {         ost1++;         if (ost1 > ost) break;         sum1 += *it;       }       ans = min(ans, sum.first + sum1);     }     cout << ans << endl;     return 0;   }   