Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#define minus1 cout<<-1<<endl;

#include<stdio.h>

#define Yes  cout<<"YES"<<endl;

#define No cout<<"NO"<<endl;

#define pb push_back

#define nl cout<<endl;

#define un unsigned;

#define FOR(l,r) for(ll i = l; i < r;i++)

#define frr(l,r) for(ll i = l; i >=r;i--)

using namespace std;

using ll = long long;









/*****************************************CODE*****************************************/





bool sortbysec(const pair<ll,ll> &a,

              const pair<ll,ll> &b)

{

    return (a.second < b.second);

}



bool sortBySecDesc(const pair<ll,ll> &a,

              const pair<ll,ll> &b)

{

    return (a.second > b.second);

}



bool customComparator(const pair<int, int>& a, const pair<int, int>& b) {

    if (a.first == b.first) {

        return a.second > b.second; // Sort in descending order of second element if first elements are equal

    }

    return a.first < b.first; // Sort in ascending order of first element

}





bool secDescFstAsc(const std::pair<int, int>& a, const std::pair<int, int>& b) {

    if (a.second != b.second) {

        return a.second < b.second; // Sort in ascending order based on second element

    } else {

        return a.first > b.first; // If second elements are equal, sort in descending order based on first element

    }

}



long long lcm(long long x, long long y){

    return (min(x, y)/__gcd(x,y))*max(x,y);

}

string s;



bool check(int i, ll n){

    if(i < 0 or i + 3 >= n) return false;



    if(s[i] == '1' and s[i + 1] == '1' and s[i + 2] == '0' and s[i + 3] == '0') return 1;

    return 0;

}



void sol(){

    int n, l, r;

    cin>>n>>l>>r;



    l--;

    r--;



    vector<int>a(n);



    for(int i = 0; i < n; i++) cin>>a[i];



    int len = r - l + 1;

    vector<int>b = a;

    long long ans1 = 0, ans = 0;

    sort(a.begin(), a.begin()+r);

    sort(b.begin()+l, b.end());

    for(int i = 0;i < len;i++) ans += a[i];

    for(int i = l; i < l + len; i++) ans1+= b[i];



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



}



int main() {

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll t;

    cin>>t;







    int i = 1;

    while(t--) {

//        cout<<i++<<' ';

        sol();

//        cout<<endl;

    }



}



Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define minus1 cout<<-1<<endl;
#include<stdio.h>
#define Yes  cout<<"YES"<<endl;
#define No cout<<"NO"<<endl;
#define pb push_back
#define nl cout<<endl;
#define un unsigned;
#define FOR(l,r) for(ll i = l; i < r;i++)
#define frr(l,r) for(ll i = l; i >=r;i--)
using namespace std;
using ll = long long;




/*****************************************CODE*****************************************/


bool sortbysec(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}

bool sortBySecDesc(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second > b.second);
}

bool customComparator(const pair<int, int>& a, const pair<int, int>& b) {
    if (a.first == b.first) {
        return a.second > b.second; // Sort in descending order of second element if first elements are equal
    }
    return a.first < b.first; // Sort in ascending order of first element
}


bool secDescFstAsc(const std::pair<int, int>& a, const std::pair<int, int>& b) {
    if (a.second != b.second) {
        return a.second < b.second; // Sort in ascending order based on second element
    } else {
        return a.first > b.first; // If second elements are equal, sort in descending order based on first element
    }
}

long long lcm(long long x, long long y){
    return (min(x, y)/__gcd(x,y))*max(x,y);
}
string s;

bool check(int i, ll n){
    if(i < 0 or i + 3 >= n) return false;

    if(s[i] == '1' and s[i + 1] == '1' and s[i + 2] == '0' and s[i + 3] == '0') return 1;
    return 0;
}

void sol(){
    int n, l, r;
    cin>>n>>l>>r;

    l--;
    r--;

    vector<int>a(n);

    for(int i = 0; i < n; i++) cin>>a[i];

    int len = r - l + 1;

    priority_queue<int, vector<int>, greater<int>> pq;

    for(int i = 0;i <= r;i++){
        pq.push(a[i]);
    }
    ll ans = 0;

    for(int i = 0; i < len; i++){
        ans+=pq.top();
        pq.pop();
    }

    for(int i = l;i < n;i++){
        pq.push(a[i]);
    }

    ll ans1 = 0;
    for(int i = 0; i < len; i++){
        ans1+=pq.top();
        pq.pop();
    }

    cout<<max(ans, ans1)<< endl;





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

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t;
    cin>>t;



    int i = 1;
    while(t--) {
//        cout<<i++<<' ';
        sol();
//        cout<<endl;
    }

}