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

Code 1:
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<unordered_set>

#include<sstream>

#include<string>

#include<set>

#include<map>

#include<queue>

 

#define ll long long

 

#define MAX 200'001

 

using namespace std;



void solve() {

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> array(n);

    for(int &a : array) {

        cin >> a;

    }



    vector<int> left_half;

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

        left_half.push_back(array[i]);

    }



    vector<int> right_half;

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

        right_half.push_back(array[i]);

    }



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

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





    ll left_sum = 0;

    int left_pointer = 0;

    int segment_pointer = l - 1;



    while(left_pointer < left_half.size() && segment_pointer < r) {

        int min_value = min(array[segment_pointer], left_half[left_pointer]);



        if(min_value == array[segment_pointer]) {

            left_sum += min_value;

            segment_pointer++;

        }



        else {

            left_sum += min_value;



            left_pointer++;

            segment_pointer++;

        }

    }



    while(segment_pointer < r) {

        left_sum += array[segment_pointer];

        segment_pointer++;

    }



    ll right_sum = 0;

    int right_pointer = 0;

    segment_pointer = l - 1;



    while(right_pointer < right_half.size() && segment_pointer < r) {

        int min_value = min(array[segment_pointer], right_half[right_pointer]);



        if(min_value == array[segment_pointer]) {

            right_sum += min_value;

            segment_pointer++;

        }



        else {

            right_sum += min_value;



            right_pointer++;

            segment_pointer++;

        }

    }



    while(segment_pointer < r) {

        right_sum += array[segment_pointer];

        segment_pointer++;

    }



    cout << min(left_sum, right_sum) << '\n';

}

 

int main() {

    

    int t;

    cin >> t;

 

    while(t--) {

        solve();

    }

  

    return 0;

}

Code 2:
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<unordered_set>

#include<sstream>

#include<string>

#include<set>

#include<map>

#include<queue>

 

#define ll long long

 

#define MAX 200'001

 

using namespace std;



void solve() {

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> array(n);

    for(int &a : array) {

        cin >> a;

    }



    vector<int> left_half;

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

        left_half.push_back(array[i]);

    }



    vector<int> right_half;

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

        right_half.push_back(array[i]);

    }



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

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



    sort(array.begin() + l - 1, array.begin() + r, greater<int>());





    ll left_sum = 0;

    int left_pointer = 0;

    int segment_pointer = l - 1;



    while(left_pointer < left_half.size() && segment_pointer < r) {

        int min_value = min(array[segment_pointer], left_half[left_pointer]);



        if(min_value == array[segment_pointer]) {

            left_sum += min_value;

            segment_pointer++;

        }



        else {

            left_sum += min_value;



            left_pointer++;

            segment_pointer++;

        }

    }



    while(segment_pointer < r) {

        left_sum += array[segment_pointer];

        segment_pointer++;

    }



    ll right_sum = 0;

    int right_pointer = 0;

    segment_pointer = l - 1;



    while(right_pointer < right_half.size() && segment_pointer < r) {

        int min_value = min(array[segment_pointer], right_half[right_pointer]);



        if(min_value == array[segment_pointer]) {

            right_sum += min_value;

            segment_pointer++;

        }



        else {

            right_sum += min_value;



            right_pointer++;

            segment_pointer++;

        }

    }



    while(segment_pointer < r) {

        right_sum += array[segment_pointer];

        segment_pointer++;

    }



    cout << min(left_sum, right_sum) << '\n';

}

 

int main() {

    

    int t;

    cin >> t;

 

    while(t--) {

        solve();

    }

  

    return 0;

}







Answer: 2