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

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll;
template<class T> std::istream& operator>>(std::istream& stream, vector<T> &v) { for (T& t: v) { stream >> t; } return stream; } template <class T> std::ostream& operator<<(std::ostream& stream, const vector<T> &v) { for (const T& t : v) { stream << t << ' '; } return stream; } template <class T, class U> std::istream& operator>>(std::istream& stream, pair<T, U>& p) { return stream >> p.first >> p.second; } template <class T, class U> std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) { return stream << p.first << ' ' << p.second << ' '; } template<typename T> void read(T& t) { cin >> t; } template<typename T, typename... TArgs> void read(T& t, TArgs&&... args) { read(t); read(forward<TArgs>(args)...); } template <typename T> void readc(T& t); template<> void readc(int& v) { scanf("%d", &v); } template<> void readc(char& v) { scanf(" %c", &v); } template<> void readc(long long& v) { scanf("%lld", &v); } template<> void readc(float& v) { scanf("%f", &v); } template<> void readc(double& v) { scanf("%lf", &v); } template<size_t sz> void readc(char (&str)[sz]) { scanf("%s", str); } template<> void readc(char*& str) { scanf("%s", str); } template<typename E, typename U> void readc(pair<E, U>& v) { readc(v.first); readc(v.second); } template<typename E> void readc(vector<E>& v) { for (E& e : v) readc(e); } template<typename T, typename... TArgs> void readc(T& t, TArgs&&... args) { readc(t); readc(forward<TArgs>(args)...); }
template <typename T> void printc(T t); template<> void printc(int v) { printf("%d ", v); } template<> void printc(char v) { printf("%c ", v); } template<> void printc(long long v) { printf("%lld ", v); } template<> void printc(float v) { printf("%f ", v); } template<> void printc(double v) { printf("%lf ", v); } template<> void printc<char *>(char *str) { printf("%s ", str); } template<> void printc<const char *>(const char *str) { printf("%s ", str); } template<typename E, typename U> void printc(const pair<E, U>& v) { printc(v.first); printc(v.second); } template<typename E> void printc(const vector<E>& v) { for (const E& e : v) printc(e); } template<typename T, typename... TArgs> void printc(const T& t, TArgs&&... args) { printc(t); printc(forward<TArgs>(args)...); } template <typename T> void __DEBUG_BASE(const T& t) { cout << t; } template <typename T, typename... TArgs> void __DEBUG_BASE(const T& t, TArgs&&... args) { __DEBUG_BASE(t); cout << ", "; __DEBUG_BASE(forward<TArgs>(args)...); } template <typename... TArgs> void __DEBUG_IMPL(TArgs&&... args) { __DEBUG_BASE(forward<TArgs>(args)...); } 
array<char, 5> VOWELS = {'a','e','i','o','u'}; bool isvowel(char ch) { return find(VOWELS.begin(), VOWELS.end(), ch) != VOWELS.end(); }; bool isupper(char ch) { return ch >= 'A' && ch <= 'Z'; } bool islower(char ch) { return ch >= 'a' && ch <= 'z'; }
#define IO ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define CF_FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define PB_FILE(nm) freopen(nm ".in", "r", stdin); freopen(nm ".out", "w", stdout)
#define debug(...) cout << "[" << (#__VA_ARGS__) << "] = "; __DEBUG_IMPL(__VA_ARGS__); cout << endl



int main()
{
    IO;
    // CF_FLIE;

    int t; readc(t);
    while(t--) {
        int n, l, r; readc(n, l, r);
        vector<int> left(l-1), middle(r-l+1), right(n-r);
        readc(left,middle,right);
        sort(left.begin(),left.end());
        sort(right.begin(),right.end());
        sort(middle.rbegin(), middle.rend());

        ll s=0;
        for(int i:middle) s+=i;
        int ln = left.size(), mn = middle.size(), rn = right.size();

        ll ls = 0, rs = 0;

        for(int i = 0; i < ln && i < mn && left[i] < middle[i]; i++) ls+=middle[i] - left[i];
        for(int i = 0; i < rn && i < mn && right[i] < middle[i]; i++) rs+=middle[i] - right[i];

        // debug(left, middle, right, ls, rs, ln, mn, rn);
        printc(s - max(ls, rs));
        puts("");
    }


    return 0;
}


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

using namespace std;



#define pb push_back

#define endl '\n'

#define YES (cout << "YES" << endl)

#define NO (cout << "NO" << endl)

#define ft first

#define sd second

#define PI 3.1415926

#define lowbit(x) (x & -x)



typedef long long LL;

typedef pair<int, int> PII;



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    priority_queue<LL, vector<LL>, greater<LL>> left, right;

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

        LL x;

        cin >> x;

        if(i <= r) {

            left.push(x);

        }

        if(i >= l) {

            right.push(x);

        }

    }

    LL sl = 0, sr = 0;

    int len = r - l + 1;

    for(int i = 1; i <= len; i ++) {

        sl += left.top();

        left.pop();

        sr += right.top();

        right.pop();

    }

    cout << min(sl, sr) << endl;

}



signed main()

{

    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int T = 1;

    cin >> T;

    while(T --)

        solve();

    

    return 0;

}