Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 92 ms):
/*

    author : abhishrestha

*/

#include <bits/stdc++.h>

using namespace std;



#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

const long long MOD = 1e9 + 7;

const long long N = 1e7;

#define no cout << "NO" << endl

#define yes cout << "YES" << endl

#define int long long

#define endl "\n"



int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sort(vector) (sort((vector).begin(), (vector).end()))

#define maxx(vector) (*max_element((vector).begin(), (vector).end()))

#define minn(vector) (*min_element((vector).begin(), (vector).end()))



#ifndef abhishrestha

#define debug(x) cerr << #x << " "; _print(x); cerr << endl;

#else 

#define debug(x)

#endif



void _print(int t) {cerr << t;}

void _print(string t) {cerr << t;}

void _print(char t) {cerr << t;}

void _print(double t) {cerr << t;}



template <class T, class V> void _print(pair <T, V> p);

template <class T> void _print(vector <T> v);

template <class T> void _print(set <T> v);

template <class T, class V> void _print(map <T, V> v);

template <class T> void _print(multiset <T> v);

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}

template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}







/*





<------------------------------MAIN CODE STARTS HERE-------------------------------->





*/ 



void solve() {

    int n, l, r;

    cin >> n >> l >> r;

     



    vector<int> arr(n);

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

        cin >> arr[i];

    }

    vector<int> a , b;

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

        a.push_back(arr[i]);

    }

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

        b.push_back(arr[i]);

    }

    sort(a);

    sort(b);

    int sum = 0;

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

        sum = sum + a[i];

    }

    int ans = sum;

    sum = 0;

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

        sum += b[i];

    }

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

}



int32_t main() {

#ifndef abhishrestha

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

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

#endif

    FAST_IO;

    int tt = 1;

    cin >> tt;

    for( int tc = 1; tc <= tt; tc++ ) {

        solve();

    }

    return 0;

}

Solution 2 (runtime: 202 ms):
#include<bits/stdc++.h>

using namespace std;





void solve()

{

  int t;

  cin>>t;



  while(t--)

  {

    int n,l,r;



    cin>>n>>l>>r;



    vector<int>arr(n);

    for(auto &val:arr)

    {

      cin>>val;

    }

   

    vector<int>arr2=arr;



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



    sort(arr2.begin()+l-1,arr2.end());



    // for(auto val:arr)cout<<val<<" ";

    //   cout<<endl;



    // for(auto val:arr2)cout<<val<<" ";

    //   cout<<endl;





    int ct=r-l+1;



    long long sum1=0,sum2=0;



   int i=0,j=l-1;

    while(ct)

    {

      sum1+=arr[i];

      sum2+=arr2[j];

      i++;

      j++;

      ct--;

    }

    // cout<<endl;



    cout<<min(sum1,sum2)<<endl;

  

  }



}



int main()

{

 solve();

  return 0;

}