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

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

#define ll long long
#define pb push_back
#define vint vector<int>
#define vlong vector<long long>
#define traverse(n) for(int i=0;i<(n.size());i++)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define rev(arr) reverse(arr.begin(),arr.end())
#define srt(arr) sort(arr.begin(),arr.end())

// map in descending order  map<int,int,greater<int>>mpp 
// max-heap--> priority_queue<int>pq; -->arranged in descending 
// min-heap --> priority_queue<int,vector<int>,greater<int>>pq -->arrange in ascending 

ll log_a_base_b(ll a, ll b){return log2(a) / log2(b);}

ll ncr(ll n,ll r){
    ll result = 1;
    for(int i = 1; i <= r; i++){
        result = result * (n - r + i) / i;
    }
    return result;
}

ll lcm(ll a, ll b) {
  return (a / __gcd(a, b)) * b;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       int n,l,r;
       cin>>n>>l>>r;
       l--;
       r--;
       vector<int> arr(n,0);
       vector<int> left(l);
       vector<int>mid(r-l+1);
       vector<int> right(n-r-1);
       for(int i=0;i<l;i++){
        cin>>left[i];
       }
       for(int i=l;i<=r;i++){
        cin>>mid[i];
       }
       for(int i=r+1;i<n;i++){
         cin>>right[i];
       }
     sort(left.begin(),left.end());
     sort(mid.begin(),mid.end()); 
     rev(mid);
     sort(right.begin(),right.end());

      // for(int i=0;i<mid.size();i++){
      //    if(i<left.size()&&i<right.size()){
      //        mid[i]=min(min(left[i],right[i]),mid[i]);
      //    }else if(i<left.size()){
      //       mid[i]=min(left[i],mid[i]);
      //    }else if(i<right.size()){
      //       mid[i]=min(right[i],mid[i]);
      //    }
      // }
      int i=0;
      ll sum=0;
      while(i<mid.size()&&i<left.size()){
        sum+=min(mid[i],left[i]);
        i++;
      }
      while(i<mid.size()){
        sum+=mid[i];
        i++;
      }
      ll sum1=0;
      i=0;
      while(i<mid.size()&&i<right.size()){
        sum1+=min(mid[i],right[i]);
        i++;
      }
      while(i<mid.size()){
        sum1+=mid[i];
        i++;
      }
     
      cout<<min(sum,sum1)<<endl;

     
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define vint vector<int>
#define vlong vector<long long>
#define traverse(n) for(int i=0;i<(n.size());i++)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define rev(arr) reverse(arr.begin(),arr.end())
#define srt(arr) sort(arr.begin(),arr.end())

// map in descending order  map<int,int,greater<int>>mpp 
// max-heap--> priority_queue<int>pq; -->arranged in descending 
// min-heap --> priority_queue<int,vector<int>,greater<int>>pq -->arrange in ascending 

ll log_a_base_b(ll a, ll b){return log2(a) / log2(b);}

ll ncr(ll n,ll r){
    ll result = 1;
    for(int i = 1; i <= r; i++){
        result = result * (n - r + i) / i;
    }
    return result;
}

ll lcm(ll a, ll b) {
  return (a / __gcd(a, b)) * b;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       int n,l,r;
       cin>>n>>l>>r;
       l--;
       r--;
       vector<int> arr(n,0);
       vector<int> left(l);
       vector<int>mid(r-l+1);
       vector<int> right(n-r-1);
       for(int i=0;i<left.size();i++){
        cin>>left[i];
       }
       for(int i=0;i<mid.size();i++){
        cin>>mid[i];
       }
       for(int i=0;i<right.size();i++){
         cin>>right[i];
       }
     sort(left.begin(),left.end());
     sort(mid.begin(),mid.end()); 
     rev(mid);
     sort(right.begin(),right.end());

     
      int i=0;
      ll sum=0;
      while(i<mid.size()&&i<left.size()){
        sum+=min(mid[i],left[i]);
        i++;
      }
      while(i<mid.size()){
        sum+=mid[i];
        i++;
      }
      ll sum1=0;
      i=0;
      while(i<mid.size()&&i<right.size()){
        sum1+=min(mid[i],right[i]);
        i++;
      }
      
      while(i<mid.size()){
        sum1+=mid[i];
        i++;
      }
     
      cout<<min(sum,sum1)<<endl;

     
    }
}