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

Previous submission (verdict: Wrong answer on test 2):
//

//Created by xll.

//

#include<bits/stdc++.h>

#define int long long

#define fi first

#define se second

using namespace std;



typedef pair<int,int> PII;



const int N = 200010;

const int inf=1e18;



void solve()

{

    int n,l,r;

    cin>>n>>l>>r;

    vector<int> a[3];

    int mi=inf;

    vector<vector<int>> s(3,vector<int>(n+1));

    for(int i=1;i<=l-1;i++)

    {

        int x;cin>>x;

        a[0].push_back(x);

        mi=min(mi,x);

    }

    for(int i=l;i<=r;i++)

    {

        int x;cin>>x;

        a[1].push_back(x);

        mi=min(mi,x);

    }

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

    {

        int x;cin>>x;

        a[2].push_back(x);

        mi=min(mi,x);

    }

    for(int i=0;i<3;i++)sort(a[i].begin(),a[i].end());

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

    {

        for(int j=0;j<a[i].size();j++)

        {

            if(!j)s[i][j]=a[i][j];

            else s[i][j]=s[i][j-1]+a[i][j];

        }

    }

    int ans=s[1][a[1].size()-1];

    int m=a[1].size()-1;

    //cout<<"ans=="<<ans<<'\n';

    for(int i=0;i<a[0].size();i++)

    {

        if(m-i-1>=0){

            ans=min(ans,s[1][m-i-1]+s[0][i]);

            //cout<<"i1=="<<i<<'\n'<<" res=="<<s[1][m-i-1]+s[0][i]<<'\n';

        }

    }



    for(int i=0;i<a[2].size();i++)

    {

        if(m-i-1>=0){

            ans=min(ans,s[1][m-i-1]+s[2][i]);

            //cout<<"i2=="<<i<<'\n'<<" res=="<<s[1][m-i-1]+s[2][i]<<'\n';

        }

    }

    if(m==0)cout<<mi<<'\n';

    else cout<<ans<<'\n';



}



signed main() 

{

    std::ios::sync_with_stdio(false);

    cin.tie(0); 

    cout.tie(0);

    int T;

    cin >> T;



    while(T --)

    {

        solve();

    }

}

Submission (verdict: Wrong answer on test 2):
//
//Created by xll.
//
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;

typedef pair<int,int> PII;

const int N = 200010;
const int inf=1e18;

void solve()
{
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a[3];
    int mi=inf;
    vector<vector<int>> s(3,vector<int>(n+1));
    for(int i=1;i<=l-1;i++)
    {
        int x;cin>>x;
        a[0].push_back(x);
        mi=min(mi,x);
    }
    for(int i=l;i<=r;i++)
    {
        int x;cin>>x;
        a[1].push_back(x);
    }
    for(int i=r+1;i<=n;i++)
    {
        int x;cin>>x;
        a[2].push_back(x);
        mi=min(mi,x);
    }
    for(int i=0;i<3;i++)sort(a[i].begin(),a[i].end());
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<a[i].size();j++)
        {
            if(!j)s[i][j]=a[i][j];
            else s[i][j]=s[i][j-1]+a[i][j];
        }
    }
    int ans=s[1][a[1].size()-1];
    int m=a[1].size()-1;
    if(m==0){
        cout<<mi<<'\n';
        return;
    }
    //cout<<"ans=="<<ans<<'\n';
    for(int i=0;i<a[0].size();i++)
    {
        if(m-i-1>=0){
            ans=min(ans,s[1][m-i-1]+s[0][i]);
        }
    }

    for(int i=0;i<a[2].size();i++)
    {
        if(m-i-1>=0){
            ans=min(ans,s[1][m-i-1]+s[2][i]);
           
        }
    }
    if(m==0)cout<<mi<<'\n';
    else cout<<ans<<'\n';

}

signed main() 
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int T;
    cin >> T;

    while(T --)
    {
        solve();
    }
}