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

Solution 1 (runtime: 93 ms):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vector<ll>> vvll;

#define fi first
#define se second
#define pb push_back
#define mod 1000000007

#define f(i,s,e) for( ll i=s; i<e; i++)
#define fa(i,a) for( auto i: a)
#define fe(i,s,e) for( ll i=s; i<=e; i++)
#define fr(i,e,s) for( ll i=e; i>=s; i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define get(a) cin >> a
#define get2(a,b) cin >> a >> b
#define get3(a,b,c) cin >> a >> b >> c

#define pnl cout << "\n"
#define print(a) cout << a << " "
#define print2(a,b) cout << a << " " << b << " "
#define print3(a,b,c) cout << a << " " << b << " " << c << " "

ll vmax(vll a) { ll mx=a[0]; fa(i,a) mx=max( i, mx); return mx; }
ll vmin(vll a) { ll mi=a[0]; fa(i,a) mi=min( i, mi); return mi; }
ll vsum(vll a) { ll sm=0; fa(i,a) sm+=i; return sm; }

ll add( ll x, ll y) { ll res=x+y; return ( res>mod ? res-mod:res ); }
ll mult( ll x, ll y) { ll res=x*y; return ( res>mod ? res%mod:res ); }
ll sub( ll x, ll y) { ll res=x-y; return ( res<0 ? res+mod:res ); }
ll pow( ll x, ll y) { ll res=1; x%=mod; while(y){ if(y&1) res=mult(res,x); y>>=1; x=mult(x,x);} return res; }

void getv(vll &a) { f(i,0,a.size()) get(a[i]); }
void getvp(vpll &a) { f(i,0,a.size()) get(a[i].fi), get(a[i].se); }
void getvv(vvll &a) { f(i,0,a.size()) f(j,0,a[0].size()) get(a[i][j]); }
void printv(vll a) { fa(i,a) print(i); pnl; }
void printvp(vpll a) { fa(i,a) print2(i.fi, i.se), pnl; }
void printvv(vvll a) { fa(i,a) { fa(j,i) print(j); pnl; }}

void yes() { print("YES"); }
void no() { print("NO"); }

void solve() {
	ll n, l, r; 
    get3( n, l, r);

    vll a(n);
    getv(a);

    vll s1=a, s2=a;
    sort( s1.begin(), s1.begin()+r);
    sort( s2.begin()+l-1, s2.end());

    ll ans1=0, ans2=0;
    for( ll i=0; i<r-l+1; i++) 
        ans1+=s1[i], ans2+=s2[l-1+i];

    print(min( ans1, ans2));
    pnl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll t; get(t);
    while(t--) 
		solve();

    return 0;
}

Solution 2 (runtime: 202 ms):
// DO NOT COPY AND PASTE CODE

// Be very sure of what you are doing before submitting

// Solve 1000+ problems of rating range 1300-1800 (400+ of 1300-1500 and 600+ for 1600-1800) before 31st December.

// Analyze the ratings of problems you are solving here https://cfviz.netlify.app/

// Dont look at test cases

#include<bits/stdc++.h>

using namespace    std;

#include <iostream>

#include <algorithm> 



#include<numeric>

// typedef long ;

// #include <iostream>

// #include <cstdlib>

// #include <ctime>

// #include <thread>

// #include <chrono>

// #include <iostream>



// // Library effective with Windows

// #include <windows.h>



// // Library effective with Linux

// #include <unistd.h>

// const ll INF = 1e9+7;











#define ll                  long long 

#define ull                 unsigned long long

// #define MOD                 1000000007 // 998244353

#define vi                  vector<int>

#define vb                  vector<bool>

#define vvi                 vector<vector<int> >

#define vll                 vector<long long>

#define pb                  push_back

#define eb                  emplace_back

#define mp(a, b)            make_pair(a, b)

#define pii                 pair<int, int>

#define vpii                vector<pair<int, int> >

#define mk(arr, n, type)    type *arr = new type[n];

#define FOR(i, a, b)        for (int(i) = (a); (i) < (b); ++(i))

#define RFOR(i, a, b)       for (int(i) = (a)-1; (i) >= (b); --(i))

#define FORALL(i, a)        for (auto& (i) : (a))

#define printall(a)         for (auto& (i) : (a)) cout << i << ' '

#define print(a)            cout << a << '\n'

#define rsort(a)            sort((a).rbegin(), (a).rend())

#define w(x)                int x; cin >> x; while(x--)

#define all(c)              (c).begin(), (c).end()

#define sz(c)               (int)(c).size()

#define pqmx                priority_queue<int>

#define pqmn                priority_queue<int, vector<int>, greater<int> >

#define max3(a, b, c)       max((a), max((b), (c)))

#define min3(a, b, c)       min((a), min((b), (c)))

#define mx_all(c)           *max_element((c).begin(), (c).end())

#define mn_all(c)           *min_element((c).begin(), (c).end())

#define lwr_b(c, a)         lower_bound((c).begin(), (c).end(), (a)) - ((c).begin())

#define upr_b(c, a)         upper_bound((c).begin(), (c).end(), (a)) - ((c).begin())

#define FIO                 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

// #define MAXN 100010

// int x[MAXN],y[MAXN],a[MAXN],degree[MAXN];

// const int MAX = 100'007;

const long long int MOD = 1000000007;



bool isprime(long long int N){

    if(N<2 || (!(N&1) && N!=2))

        return 0;

    for(int i=3; i*i<=N; i+=2){

        if(!(N%i))

            return false;

    }

    return true;

}



long long int factorial(long long int n) {

    if (n <= 1) {  

        return 1;

    } else {

        return (n * factorial(n - 1));  

    }

}



void upd(int &a, int b) {

    a = (a * 1LL * b) % MOD;

}

// #define sz(a) int((a).size())

// #define forn(i, n) for (int i = 0; i < int(n); ++i)



long long int gcd(long long int a, long long int b) {

    while (b != 0) {

        long long int temp = b;

        b = a % b;  // Get the remainder

        a = temp;   // Update a to the previous value of b

    }

    return a;

}



long long int powerMod(long long int base, long long int exponent, long long int mod) {

    long long int result = 1;

    base = base % mod;    



    while (exponent > 0) {

        if (exponent % 2 == 1) {

            result = (result * base) % mod;

        }

        exponent = exponent >> 1;  

        base = (base * base) % mod; 

    }



    return result;

}





double roundToSixDecimalPlaces(double value) {

    return std::round(value * 1e6) / 1e6;

}

vector<ll> parent,component;



ll find(ll x){

    if(x==parent[x]) return x;

    return parent[x]=find(parent[x]);

}



void unite(ll a, ll b){

    a=find(a);

    b=find(b);

    if(a!=b){

        if(component[a]<component[b]){

            swap(a,b);

        }

        parent[b]=a;

        component[a]+=component[b];

    }

}





ull ull_abs(ull a, ull b) {

    return (a > b) ? (a - b) : (b - a);

}



const int MAXN = 200200;





void dfsRecursive(int vertex, vector<bool>& visited, const vector<vector<int>>& adjList) {

    visited[vertex] = true;  



    for (int neighbor : adjList[vertex]) {

        if (!visited[neighbor]) {

            dfsRecursive(neighbor, visited, adjList);

        }

    }

}





long long power(long long a, long long b)

{

    long long res = 1;

    while (b > 0) {

        if (b%2==1) {

            res = (res * a);

        }

        a*=a;

        b >>= 1;

    }

    return res;

}



long long lcm(int a, int b) {

    return (1LL * a * b) / __gcd(a, b);

}



int pb, pc, ps;

int nb, nc, ns;

int lb, lc, ls;

ll fb, fc, fs;



const int MAX_VAL = 1000001;



ll price(ll x)

{

    fb = max(x*lb - nb, (ll)0);

    fc = max(x*lc - nc, (ll)0);

    fs = max(x*ls - ns, (ll)0);



    ll p = fb*pb + fc*pc + fs*ps;

    return p;

}



// const ll INF = ll(1E18)+16;

 



void solve() {

    

    long long int n, l, r;

        cin >> n >> l >> r;

        l--;  // Convert to 0-based index



        vector<long long int> arr(n);

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

            cin >> arr[i];

        }



        // Create brr and crr

        vector<long long int> brr = arr;

        sort(brr.begin() + l, brr.end());  // Sort the portion from l to n



        vector<long long int> crr = arr;

        sort(crr.begin(), crr.begin() + r);  // Sort the portion from 0 to r

        reverse(crr.begin(), crr.begin() + r); // Reverse the sorted portion



        // Calculate the sums and prlong long int the minimum

        long long int sum_brr = 0, sum_crr = 0;

        for (long long int i = l; i < r; ++i) {

            sum_brr += brr[i];

            sum_crr += crr[i];

        }



        cout << min(sum_brr, sum_crr) << endl;

    



}



int main(){

   int t;

   cin>>t;

   while(t--){

    solve();

   }

    

   return 0;

}