Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 92 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define sc second
#define PI acos(-1.0)
#define MOD 1000000007
#define endl '\n'
#define eb emplace_back
#define set(n, k) (n = (1LL << k))
#define unset(n, k) (n &= ~(1LL << k))
#define check(n , k) (n & (1LL << k))
#define toggle(n, k) (n ^ (1LL << k))
#define fastio std::ios_base::sync_with_stdio (false); cin.tie(0); cout.tie(0);
int popcount(ll n) {return __builtin_popcountll(n);}
int poplow(ll n) {return __builtin_ctzll(n);}
int pophigh(ll n) {return 63 - __builtin_ctzll(n);}
ll PERFECT_NUM[]={6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128};
//-----------------------------------------------------------------------------------
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    return ((a/gcd(a,b))*b);
}

ll BigMod(ll a, ll p, ll m){
    ll ret=1;
    while(p){
        if(p&1) ret=((ret%m)*(a%m))%m;
        a=((a%m)*(a%m))%m;
        p/=2;
    }
    return ret;
}
ll AddMul(ll a, ll p, ll m){
    ll ret=0;
    while(p){
        if(p&1) ret=((ret%m)+(a%m))%m;
        a=((a%m)+(a%m))%m;
        p /= 2;
    }
    return ret;
}
void iofile(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
//-------------------------------------------------------------------------
 /*TO GET SOMETHING YOU NEVER HAD YOU HAVE TO DO SOMETHING YOU NEVER DID*/
//-------------------------------------------------------------------------

void solve(){
    int n, l, r;
    cin >> n >> l >> r;
    vector<ll>v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    vector<ll>temp;
    for(int i = 0; i < r; i++) temp.push_back(v[i]);
    sort(temp.begin(), temp.end());
    ll xx = 0, ans;
    for(int i = 0; i < r - l + 1; i++) xx += temp[i];
    ans = xx;
    xx = 0; temp.clear();
    for(int i = l-1; i < n; i++) temp.push_back(v[i]);
    sort(temp.begin(), temp.end());
    for(int i = 0; i < r - l + 1; i++) xx += temp[i];
    ans = min(ans, xx);

    cout << ans << endl;
}


int main(){
    fastio;
    iofile();
    int t=1, tc=1;
    cin>>t;
    //cin.ignore();
    while(t--){
        //cout<<"Case "<<tc++<<": ";
        solve();
    }

    return 0;
}


Solution 2 (runtime: 202 ms):
#include<bits/stdc++.h>

#include<iostream>

#include<vector>

using namespace std;

#define ll long long

ll gcd(ll a, ll b)

{

    if (a == 0)

        return b;

    return gcd(b % a, a);

}

ll mod = 1e9 +7;





    bool isPrime(int n) {

    if (n <= 1)

        return false;

    for (int i = 2; i <= sqrt(n); i++)

        if (n % i == 0)  

            return false;

    return true;

}



ll solve(vector<ll>v,vector<ll>v1){

    ll ans = 0;

    int i = v.size()-1;

    int j = 0;

    while(j<v1.size()&&i>=0){

        if(v[i]>v1[j]){

            ans+=v1[j];

            j++;i--;

        }

        else{

            j++;

        }

    }

    while(i>=0){

        ans+=v[i];

        i--;

    }

    return ans;

}



int main(){

   int tc;cin>>tc;

   while(tc--){

    int n,l,r;cin>>n>>l>>r;

    vector<ll>v1(l-1);

    vector<ll>v(r-l+1);

    vector<ll>v2(n-r);

    for(int i=0;i<l-1;i++){

        cin>>v1[i];

    }

    for(int i=0;i<r-l+1;i++){

        cin>>v[i];

    }

    for(int i=0;i<n-r;i++){

        cin>>v2[i];

    }

    sort(v1.begin(),v1.end());

    sort(v2.begin(),v2.end());

    sort(v.begin(),v.end());

    // for(auto i:v2){

    //     cout<<i<<" ";

    // }

    ll ans = min(solve(v,v1),solve(v,v2));

    cout<<ans<<endl;

   }

return 0;

}