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

Solution 1 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define       forn(i, n)             for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
#define            pb                push_back
#define            vi                vector<int>
#define            vvi               vector<vector<int>>
#define            vll               vector<ll>
#define            vvll              vector<vector<ll>>
#define            ll                long long
// #define int long long
void lilAref()
{
 cin.tie(0);
 cout.tie(0);
 ios_base::sync_with_stdio(false);
}

ll modProd(ll a, ll b, ll mod)
{
    if (a < 0)
        a += mod;
    if (b < 0)
        b += mod;
    a *= b;
    if (a >= mod)
        a %= mod;
    return a;
}

ll modPow(int a, ll b,ll mod) {
    int result = 1;
    while (b) {
        if (b & 1)
            result = modProd(result, a,mod);
        a = modProd(a, a,mod);
        b >>= 1;
    }
    return result;
}

vector<ll> divisors(ll n) {
    vector<ll>divis;
    for (ll i = 1;i * i <= n;i++) {
        if (n % i == 0) {
            divis.push_back(i);
            if (n != i * i)divis.push_back(n / i);
        }
    }
    return divis;
}

signed main(){
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    lilAref();
    int tt;cin>>tt;
    while (tt--) {
        int n,l,r;cin>>n>>l>>r;
        vector<ll>range,left,right;
        ll sum = 0;
        for (int i=1;i<=n;i++) {
            int a;cin>>a;
            if (i<l)
                left.push_back(a);
            else if (i>r)
                right.push_back(a);
            else {
                range.push_back(a);sum+=a;
            }
        }
        sort(all(left));
        sort(all(right));
        sort(all(range));
        int cnt = r-l+1;
        ll ltot=sum;
        ll rtot= sum;
        int ind=0;
        if (left.size()) {
            for (int i=range.size()-1;i>=0 && ind<left.size();i--) {
                if (range[i]<left[ind])
                    break;
                ltot-=range[i];
                ltot+=left[ind++];
            }
        }
        ind=0;
        if (right.size()) {
            for (int i=range.size()-1;i>=0 and ind<right.size();i--) {
                if (range[i]<right[ind])
                    break;
                rtot-=range[i];
                rtot+=right[ind++];
            }
        }
        cout<<min(ltot,rtot)<<endl;
    }

}

Solution 2 (runtime: 92 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
void solve(ll tc)
{
    ll n,l,r,i,s1=0,s2=0,a,p;
    cin>>n>>l>>r;
    p=r-l+1;
    vector<ll>v1,v2;
    for(i=0; i<n; i++)
    {
        cin>>a;
        if(i<r) v1.pb(a);
        if(i>=l-1) v2.pb(a);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    for(i=0; i<p; i++) s1+=v1[i],s2+=v2[i];
    ll s=min(s1,s2);
    cout<<s<<endl;




}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
    cin>>tc;
    for(ll i=1; i<=tc; i++)
    {
        solve(i);
    }
}