Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef vector<string> vs;

typedef vector<double> vd;

typedef vector<vector<int> > vvi;

typedef vector<vector<long long> > vvll;

typedef vector<vector<string> > vvs;

typedef vector<vector<double> > vvd;

#define pb push_back

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

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

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

// #define FOR2D(i, j, n, m) for (int i = 0; i < (n); i++) for (int j = 0; j < (m); j++)

#define FOR2D(i, j, start_i, end_i, start_j, end_j) \

    for (int i = (start_i); i < (end_i); ++i)       \

        for (int j = (start_j); j < (end_j); ++j)

#define FORE(item, container) for (auto &item : container)

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

#define NL std::cout << "\n"

#define MOD 1000000007



void solve()

{

    int n, l, r;

    cin>>n>>l>>r;

    vi arr(n);

    FOR(i, 0, n) {

        cin>>arr[i];

    }

    priority_queue<int> pq;

    priority_queue<int, vector<int>, greater<int> > a, b;

    FOR(i, l-1, r)

        pq.push(arr[i]);

    FOR(i, 0, l-1)

        a.push(arr[i]);

    FOR(i, r, n)

        b.push(arr[i]);

    

    ll sum = 0;

    ll minSum = INT_MAX;

    while(!pq.empty()) {

        if(a.empty()) {

            sum += pq.top();

        }

        else {

            sum += min(a.top(), pq.top());

            a.pop();

        }

        pq.pop();

    }

    minSum = min(minSum, sum);



    FOR(i, l-1, r)

        pq.push(arr[i]);



    sum = 0;

    while(!pq.empty()) {

        if(b.empty()) {

            sum += pq.top();

        }

        else {

            sum += min(b.top(), pq.top());

            b.pop();

        }

        pq.pop();

    }

    minSum = min(minSum, sum);



    cout << minSum;

    NL;

}



int main()

{

    // #ifndef ONLINE_JUDGE

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

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

    // #endif

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<long long> vll;

typedef vector<string> vs;

typedef vector<double> vd;

typedef vector<vector<int> > vvi;

typedef vector<vector<long long> > vvll;

typedef vector<vector<string> > vvs;

typedef vector<vector<double> > vvd;

#define pb push_back

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

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

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

// #define FOR2D(i, j, n, m) for (int i = 0; i < (n); i++) for (int j = 0; j < (m); j++)

#define FOR2D(i, j, start_i, end_i, start_j, end_j) \

    for (int i = (start_i); i < (end_i); ++i)       \

        for (int j = (start_j); j < (end_j); ++j)

#define FORE(item, container) for (auto &item : container)

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

#define NL std::cout << "\n"

#define MOD 1000000007



void solve()

{

    int n, l, r;

    cin>>n>>l>>r;

    vll arr(n);

    FOR(i, 0, n) {

        cin>>arr[i];

    }

    priority_queue<ll> pq;

    priority_queue<ll, vector<ll>, greater<ll> > a, b;

    FOR(i, l-1, r)

        pq.push(arr[i]);

    FOR(i, 0, l-1)

        a.push(arr[i]);

    FOR(i, r, n)

        b.push(arr[i]);

    

    ll sum = 0;

    ll minSum = LONG_MAX;

    while(!pq.empty()) {

        if(a.empty()) {

            sum += pq.top();

        }

        else {

            sum += min(a.top(), pq.top());

            a.pop();

        }

        pq.pop();

    }

    minSum = min(minSum, sum);



    FOR(i, l-1, r)

        pq.push(arr[i]);



    sum = 0;

    while(!pq.empty()) {

        if(b.empty()) {

            sum += pq.top();

        }

        else {

            sum += min(b.top(), pq.top());

            b.pop();

        }

        pq.pop();

    }

    minSum = min(minSum, sum);



    cout << minSum;

    NL;

}



int main()

{

    // #ifndef ONLINE_JUDGE

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

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

    // #endif

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}