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

Previous submission (verdict: Wrong answer on test 2):
/* परिवर्तिनि संसारे मृतः को वा न जायते |

   स  जातो येन जातेन याति वंश समुन्नतिम्||  */

   

#include<bits/stdc++.h>

#define Fastio ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

typedef long double lld;

typedef unsigned long long ull;

typedef long long ll;



constexpr int MOD=1e9+7;



#ifdef ARPIT

#include "karpit.h"

#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define deb(x...)

#endif





signed main() {

Fastio

#ifdef ARPIT

    freopen("error.txt", "w", stderr);

#endif

    int t  = 1;

    cin>>t; 

    // Solve Here 

    while(t--){

      ll n,l,r;

      cin>>n>>l>>r;

      vector<ll> a(n);

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

        cin>>a[i];

      }

      if(l-2>=0) sort(a.begin(),a.begin()+l-2);

      sort(a.begin()+l-1,a.begin()+r);

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



      deb(a);

      

      int i=r-1,j=r;

      ll sum1=0,sum2=0;

      while(i>=l-1){

        if(j<n)sum1+=min(a[i],a[j]);

        else{

          sum1+=a[i];

        }

        i--;

        j++;

      }

      i=r-1,j=0;

      while(i>=l-1){

        if(j<l-1) sum2+=min(a[i],a[j]);

        else sum2+=a[i];

      

        i--;j++;

      }



      cout<<min(sum1,sum2)<<"\n";

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
/* परिवर्तिनि संसारे मृतः को वा न जायते |

   स  जातो येन जातेन याति वंश समुन्नतिम्||  */

   

#include<bits/stdc++.h>

#define Fastio ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

typedef long double lld;

typedef unsigned long long ull;

typedef long long ll;



constexpr int MOD=1e9+7;



#ifdef ARPIT

#include "karpit.h"

#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)

#else

#define deb(x...)

#endif





signed main() {

Fastio

#ifdef ARPIT

    freopen("error.txt", "w", stderr);

#endif

    int t  = 1;

    cin>>t; 

    // Solve Here 

    while(t--){

      ll n,l,r;

      cin>>n>>l>>r;

      vector<ll> a(n);

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

        cin>>a[i];

      }

      vector<ll> copy(a.begin()+l-1,a.begin()+r),ano;

      sort(copy.rbegin(),copy.rend());

      deb(copy);

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

        if(i<l-1||i>r-1){

          ano.push_back(a[i]);

        }

      }

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



      int i=0;

      ll ans=0;

      while(i<copy.size()){

        if(i<ano.size()) ans+=min(copy[i],ano[i]);

        else ans+=copy[i];

        i++;

      }

      cout<<ans<<"\n";

      // if(l-2>=0) sort(a.begin(),a.begin()+l-2);

      // sort(a.begin()+l-1,a.begin()+r);

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



      // deb(a);

      

      // int i=r-1,j=r;

      // ll sum1=0,sum2=0;

      // while(i>=l-1){

      //   if(j<n)sum1+=min(a[i],a[j]);

      //   else{

      //     sum1+=a[i];

      //   }

      //   i--;

      //   j++;

      // }

      // i=r-1,j=0;

      // while(i>=l-1){

      //   if(j<l-1) sum2+=min(a[i],a[j]);

      //   else sum2+=a[i];

      

      //   i--;j++;

      // }



      // cout<<min(sum1,sum2)<<"\n";

    }

    return 0;

}