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

Solution 1 (runtime: 77 ms):
/*

░██████╗██╗░░██╗███████╗██╗░░██╗░█████╗░██████╗░

██╔════╝██║░░██║██╔════╝██║░░██║██╔══██╗██╔══██╗

╚█████╗░███████║█████╗░░███████║███████║██████╦╝

░╚═══██╗██╔══██║██╔══╝░░██╔══██║██╔══██║██╔══██╗

██████╔╝██║░░██║███████╗██║░░██║██║░░██║██████╦╝

╚═════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░

*/

#include <iostream>

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"

#define ll long long

#define ull unsigned long long

#define ld long double

#define pb push_back

#define pf push_front

#define pp pop_back()

#define mm multimap

#define um unordered_map

struct custom_hash

{

  size_t operator()(int key) const

  {

    return key ^ (key >> 16);

  }

};

#define umm unordered_multimap

#define ms multiset

#define us unordered_set

#define ums unordered_multiset

#define pq priority_queue

#define gcd __gcd

#define PI 3.14159265358979323846

#define MOD 1000000007

#define yes cout << "YES\n"

#define no cout << "NO\n"

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

#define allr(arr) arr.rbegin(), arr.rend()

#define mx(v) *max_element(all(v))

#define mn(v) *min_element(all(v))

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

#define ones __builtin_popcountll

const ld eps = 1e-6;

int T = 1;

inline void Shehab()

{

  ios_base::sync_with_stdio(0);

  cin.tie(0);

  cout.tie(0);



#ifndef ONLINE_JUDGE

  freopen("input.txt", "r", stdin);

  freopen("output.txt", "w", stdout);

#endif

}

inline void Tests()

{

  cin >> T;

}

void Solve()

{

  ll n, l, r;

  cin >> n >> l >> r;

  vector<ll> arr(n), before, after;

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

  {

    cin >> arr[i];

    if (i >= l - 1 && i < r)

      before.pb(arr[i]), after.pb(arr[i]);

    if (i < l - 1)

      before.pb(arr[i]);

    if (i >= r)

      after.pb(arr[i]);

  }

  sort(all(before));

  sort(all(after));

  ll kam = r - l + 1, ans1 = 0, ans2 = 0;

  while (kam--)

    ans1 += before[kam];

  kam = r - l + 1;

  while (kam--)

    ans2 += after[kam];

  cout << min(ans1, ans2) << endl;

}

int main()

{

  Shehab();

  Tests();

  while (T--)

    Solve();

}

/*

 */

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

using namespace std;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    v.resize(r + 1);

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.end(), greater<int> ());

    ll i = 0, j = l, k = 0;

    while(j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.end(), 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    if(n == 1)

    {

        int x;

        cin >> x;

        cout << x << "\n";

        return ;

    }

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    return 0;

}