Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int t;
    cin>>t;
    while(t--){
       int n,l,r ;
       cin>>n>>l>>r;
       priority_queue<int>pq;
       vector<int>arr(n,0);
       for(int i = 0 ; i<n ;i++){
           cin>>arr[i];
       }
       
       int sum1 = 0 ;
       for(int i = (l-1) ; i<= (r-1) ; i++){
           pq.push(arr[i]);
           sum1 += arr[i];
       }
       int sum2 = sum1 ;
       
       vector<int>right ;
       vector<int>left ;
       for(int i = r ; i< n ; i++){
           right.push_back(arr[i]);
       }
       
       for(int i = 0 ; i< l ; i++){
           left.push_back(arr[i]);
       }
       
       sort(left.begin(),left.end());
       sort(right.begin(),right.end());
       
       
       vector<int>temp ;
       int r_i = 0 ;
       while(!pq.empty()){
           int y = pq.top();
           if(r_i < right.size() && y > right[r_i] ){
               pq.pop();
               sum1 -= y ;
               sum1 += right[r_i];
               r_i++;
               temp.push_back(y);
           }
           else{
               break;
           }
       }
       
       for(auto x : temp){
           pq.push(x);
       }
       
       int l_i = 0 ;
       while(!pq.empty()){
           int y = pq.top();
           if(l_i < left.size() && y > left[l_i] ){
               pq.pop();
               sum2 -= y ;
               sum2 += left[l_i];
               l_i++;
              
           }
           else{
               break;
           }
       }
       
       int ans = min(sum1,sum2);
       
       cout<<ans<<endl;
       
       
    }
}


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

using namespace std;

#define int long long



signed main(){

    int t;

    cin>>t;

    while(t--){

       int n,l,r ;

       cin>>n>>l>>r;

       priority_queue<int>pq;

       vector<int>arr(n,0);

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

           cin>>arr[i];

       }

       

       int sum1 = 0 ;

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

           pq.push(arr[i]);

           sum1 += arr[i];

       }

       

       int sum2 = sum1 ;

       

       vector<int>right ;

       vector<int>left ;

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

           right.push_back(arr[i]);

       }

       

       for(int i = 0 ; i< l ; i++){

           left.push_back(arr[i]);

       }

       

       sort(left.begin(),left.end());

       sort(right.begin(),right.end());

       

       

       vector<int>temp ;

       int r_i = 0 ;

       while(!pq.empty()){

           int y = pq.top();

           if(r_i < right.size() && y > right[r_i] ){

               pq.pop();

               sum1 -= y ;

               sum1 += right[r_i];

               r_i++;

               temp.push_back(y);

           }

           else{

               break;

           }

       }

       

       for(auto x : temp){

           pq.push(x);

       }

       

       int l_i = 0 ;

       while(!pq.empty()){

           int y = pq.top();

           if(l_i < left.size() && y > left[l_i] ){

               pq.pop();

               sum2 -= y ;

               sum2 += left[l_i];

               l_i++;

              

           }

           else{

               break;

           }

       }

       

       int ans = sum2 ;

       ans = min({ans,sum1,sum2});

       

       cout<<ans<<endl;

       

       

    }

}