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

Solution 1 (runtime: 109 ms):
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll dim=2*(1e6+22);
const ll inf=1e18+77;

#define endl "\n"
#define vll vector<ll>
#define fi first
#define pb push_back
#define se second
ll mn, n, cm, sat, c, l, r, k, m, t;
ll  res[dim], cnt[dim];
ll all=0;
ll  b[dim];
ll a[dim];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>l>>r;
        for(int i=1; i<=n; i++){
            cin>>a[i];

        }
        vll suf;
        vll prf;
        ll mn=inf;
        ll sum=0;

        for(int i=1; i<=r; i++){
            prf.push_back(a[i]);
        }
        for(int i=l; i<=n; i++){
            suf.push_back(a[i]);
        }
        sort(suf.begin(), suf.end());
        sort(prf.begin(), prf.end());
        ll cur=0;
        for(int i=1; i<=(r-l+1); i++){
            cur+=suf[i-1];
        }
        mn=min(mn, cur);
        cur=0;
        for(int i=1; i<=(r-l+1); i++){
            cur+=prf[i-1];
        }
        mn=min(mn, cur);
        cout<<mn<<endl;

    }





    return 0;
}


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

using namespace std;

#define ll                    long long

#define ld                    long double

#define pb                    push_back

#define lb                    lower_bound

#define ub                    upper_bound

#define ff                    first

#define ss                    second

#define maxpq                 priority_queue <ll> pq;

#define minpq                 priority_queue <ll, vector<ll>, greater<ll> > pq;

#define inpv(v)               for(auto &x: v) cin>>x;

#define fr(i,n)               for (ll i=0;i<n;++i)

#define all(str)              sort(str.begin(), str.end())

#define pll                   pair<ll,ll>

#define printv(v)             for(auto &i: v){cout << i << " ";} cout << endl;

#define printmap(mp)          for(auto &i: mp){cout << i.first << " "<<i.second<<endl;}

#define printset(st)          for(auto &i: st){cout << i << " ";} cout << endl;

#define line                  cout<<"----------------------------------------"<<endl;

#define arrow                 cout<<"--->";

#define debugmap(mp)          for(auto &i: mp){cout << i.ff << "-->" << i.ss <<endl;} cout << endl;

#define debugset(st)          for(auto &i: st){cout << i << " ";} cout << endl;

#define faster                ios_base::sync_with_stdio(false);cin.tie(NULL);

#define sp(x)                 fixed<<setprecision(x)

#define PI                    3.141592653589793238

#define bpl(n)                __builtin_popcountll(n);

#define md                    998244353

#define modval                1000000007

#define endl                   " \n"

/*----------------------------------------------------------------------------------------------------------- */



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;



void solve()

{

ll n,l,r; cin>>n>>l>>r;

ll a[n];

for(auto&u:a)cin>>u;

vector<int>b;

vector<int>c;

l--,r--;

for(ll i=l;i<n;i++)b.push_back(a[i]);

for(ll i=0;i<=r;i++)c.push_back(a[i]);

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

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

ll lsum=accumulate(b.begin(),b.begin()+(int)(r-l+1),0ll);

ll rsum=accumulate(c.begin(),c.begin()+(int)(r-l+1),0ll);

cout<<min(lsum,rsum)<<endl;

}



int main()

{



    faster;



    ll t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}