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

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

using namespace std;

#define setbitcounts(x)   __builtin_popcountll(x)

#define ll                long long

#define pb                push_back

#define ppb               pop_back

#define pf                push_front

#define ppf               pop_front

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

#define uniq(v)           (v).erase(unique(all(v)),(v).end())

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

#define fr                first

#define sc                second

#define pii               pair<int,int>

#define pll               pair<long,long>

#define vii               vector<int,int>

#define vll               vector<long,long>

#define mii               map<int,int>

#define mci               map<char,int>

#define sti               set<int>

#define stc               set<char>

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

#define mem0(a)           memset(a,0,sizeof(a))

#define mem1(a)           memset(a,-1,sizeof(a))

#define mem0(a)           memset(a,0,sizeof(a))

#define ppcll             __builtin_popcountll

#define see(x) cerr << "\n" << (#x) << " is " << (x) << endl

#define out(x) cout << x << " ";

#define nl cout << "\n";

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

template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}

template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}



const long long INF=1e18;

const int32_t M32=1e9+7;

const int32_t MM32=998244353;

const int N=0;

//ascii value A=65,Z=90,a=97,z=122





ll BS(ll l, ll r, vector<pair<ll,pair<ll,ll>>> &v, ll value){

    ll ans = -1;

    while(l <= r){

        ll mid = (l+r) >> 1L;

        if(v[mid].first < value){

            ans = mid;

            l = mid+1;

        }

        else r = mid-1;

    }

    return ans;

}





int main()

{

IOS

ll t; cin >> t;

while(t--){

ll n, l,r;

cin >> n >> l >> r;



ll k = r-l+1;



vector<ll>v(n);

rep(i,0,n) cin >> v[i];



ll ans1 = 0;

vector<ll>a;

rep(i,0,r) a.push_back(v[i]);

sort(all(a));

rep(i,0,k) ans1 += a[i];



ll ans2 = 0;

vector<ll>b;

rep(i,l-1,n) b.push_back(v[i]);

sort(all(b));

rep(i,0,k) ans2 += b[i];



ll ans = min(ans1,ans2);

cout << ans << endl;

cout << endl;

}





return 0;

}

Solution 2 (runtime: 202 ms):
#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> v(n);
    for (auto &val : v) cin >> val;

    multiset<int> mt;
    for (int i = l - 1; i < r; i++) {
        mt.insert(v[i]);
    }

    for (int i = 0; i < l - 1; i++) {
        mt.insert(v[i]);
    }

    int sum = 0, k = r - l + 1;
    for (int i = 0; i < k; i++) {
        sum += *mt.begin();
        mt.erase(mt.begin());
    }

    multiset<int> m;
    for (int i = l - 1; i < r; i++) {
        m.insert(v[i]);
    }
    for (int i = r; i < n; i++) {
        m.insert(v[i]);
    }

    int sum2 = 0;
    for (int i = 0; i < k; i++) {
        sum2 += *m.begin();
        m.erase(m.begin());
    }

    int ans = min(sum, sum2);
    cout << ans << '\n';
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}