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

Solution 1 (runtime: 218 ms):
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
	int t; cin >> t;
	while(t--){
		int n, l, r; cin >> n >> l >> r;
		int a[n + 100]; for(int i = 0; i < n; i++) cin >> a[i];
		int b[n - l + 1 + 100], c[r - 1 + 1 + 100];
		for(int i = l - 1; i < n; i++) b[i - l + 1] = a[i];
		for(int i = 0; i < r; i++) c[i] = a[i];
		sort(b, b + n - l + 1);
		sort(c, c + r);
		ll s1, s2;
		s1 = s2 = 0LL;
		for(int i = l; i <= r; i++) s1 += b[i - l];
		for(int i = l; i <= r; i++) s2 += c[i - l];
		cout << min(s1, s2) << "\n";
	}
	return 0;
}
		
		

Solution 2 (runtime: 77 ms):
using namespace std;

#include <iostream>

#include <string>

#include <bits/stdc++.h>

#include <algorithm>

#include <cctype>

#define ll long long

const ll N=2e5+10;

bool prime[N];

ll factor(ll n) {

    ll ans=n;

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

        if(n%i==0) {

            while (n % i == 0) {

                n /= i;

            }

            ans -= ans / i;

        }

    }

    if (n > 1) { ans-=ans/n; }

    return ans;

}

vector<ll> prime_divisors(int n){

    vector<ll>ret;

    if(prime[n])ret.push_back(n);

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

        if(n%i==0&&prime[i]){

            ret.push_back(i);

            if((n/i!=i)&&prime[n/i])ret.push_back(n/i);

        }

    }

    return ret;

}

void Sieve(ll n)

{

    memset(prime,true,sizeof(prime));

    for(ll p=2; p*p<=n; p++)

    {

        if(prime[p])

        {

            for(ll i=p*p; i<=n; i+=p)

            {

                prime[i]=false;

            }

        }

    }

}

ll FastExpo (ll base, ll power) {

    ll result = 1;

    while (power) {

        if (power%2) {

            result *= base;

        }

        base *= base;

        power /= 2;

    }

    return result;

}

ll OddSum(ll n){

    if(n%2){

        ll k=(n+1)/2;

        return (k*k);

    }

    else{

        ll k=(n)/2;

        return (k*k);

    }

}

ll CeilDivision(ll a,ll b){

    return (a+b-1) / b;

}

int dx[]={-1, 0, 1, 0};

int dy[]= {0, -1, 0, 1};

void fast()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

}

bool comp(const pair<ll,ll>&a , const pair<ll,ll>&b){

    return b.second>a.second;

}

vector<bool>visited(N,false);

vector<int>AdjList[N];

void dfs(int node){

    if(visited[node]){

        return;

    }

    visited[node]=true;

    for(int n: AdjList[node]){

        dfs(n);

    }

}

queue<int>qu;

vector<int>dis(N,0);

void bfs(int node){



    if (!visited[node]) {

        queue<int> q;

        q.push(node);

        visited[node] = true;

        while (!q.empty()) {

            int current_node = q.front();

            q.pop();

            for (int neighbor : AdjList[current_node]) {

                if (!visited[neighbor]) {

                    visited[neighbor] = true;

                    q.push(neighbor);

                }

            }

        }

    }

}

void solve() {

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

    l--;

    r--;

    vector<ll>segment,l_v,r_v;

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

        ll x;cin>>x;

        if(i>=l && i<=r){

            segment.push_back(x);

        }

        else if(i<l){

            l_v.push_back(x);

        }

        else{

            r_v.push_back(x);

        }

    }

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

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

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

    ll l_sum=0,r_sum=0;

    ll l_temp=0,r_temp=0;

    for(int i=segment.size()-1;i>=0;i--){

        if(l_temp<l_v.size()){

            if(l_v[l_temp]<segment[i]){

                l_sum+=l_v[l_temp];

                l_temp++;

            }

            else{

                l_sum += segment[i];

            }

        }

        else {

            l_sum += segment[i];

        }

    }

    for(int i=segment.size()-1;i>=0;i--){

        if(r_temp<r_v.size()){

            if(r_v[r_temp]<segment[i]){

                r_sum+=r_v[r_temp];

                r_temp++;

            }

            else{

                r_sum += segment[i];

            }

        }

        else {

            r_sum += segment[i];

        }

    }

    cout<<min(l_sum,r_sum)<<endl;

}

int main() {

/*

#ifndef ONLINE_JUDGE

    freopen("art.in", "r", stdin);

    freopen("art.out", "w", stdout);

#endif

*/

    fast();

    int t=1;cin>>t;

    while(t--){

        solve();

    }

    return 0;

}