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

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

#define ll long long

using namespace std;

void solve();

int main()

{

    ll t;

    cin>>t;

    while(t--)

	{

		ll n;

		ll x,y;

		cin>>n>>x>>y;

		vector<ll>a,b,c;

		for(ll i=0;i<n;i++)

		{

			ll d;

			cin>>d;

			if(i<x-1)

			a.push_back(d);

			else if(i>=x-1 and i<y)

			b.push_back(d);

			else 

			c.push_back(d);

			

		}

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

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

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

		ll ans1=0,ans2=0;

		int n1=b.size()-1;

		int n2=a.size()-1,x1=0;

		for(int i=n1;i>=0;i--)

		{

			if(x1<=n2)

			{

				ans1+=min(a[x1],b[i]);

				x1++;

			}

			else

			{

			    ans1+=b[i];	

			}

		}

		

		int n3=c.size()-1,x2=0;

		for(int i=n1;i>=0;i--)

		{

			if(x2<=n3)

			{

				ans2+=min(c[x2],b[i]);

				x2++;

			}

			else

			{

			    ans2+=b[i];	

			}

		}

		cout<<min(ans1,ans2)<<endl;

    }

}



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

#include<climits>

#include<vector>

#include<iterator>

using namespace std;



void sortColumns(vector<vector<long long>>& matrix) {

    // Get the number of rows and columns

    long long  rows = matrix.size();

    long long cols = matrix[0].size();



    // Sort each column individually

    for (int j = 0; j < cols; ++j) {

        // Create a temporary vector to store the j-th column

        vector<int> temp;



        // Copy the j-th column into the temporary vector

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

            temp.push_back(matrix[i][j]);

        }



        // Sort the temporary vector in ascending order

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



        // Copy the sorted values back to the j-th column of the matrix

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

            matrix[i][j] = temp[i];

        }

    }

}



int bs(vector<int> &b,int search)

{

    int n=b.size();

     long long l=0;

 long long h=n-1;

    while(l<=h)

    {

        int mid=(l+h)/2;

        if(b[mid]==search)

        return mid;

        else if(b[mid]>search)

        {

            h=mid-1;



        }

        else

        {

            l=mid+1;

        }

        

    }

}



bool compare(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}



bool asce(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}





bool fdiv(int i,int n)

{

    if(n%i==0 || (n%(n-i))==0)

    return true;

    else

    {

        return false;

    }

}



bool f(long long mid,vector<int> a,int n)

{

    long long cnt=0;

    int x=0;

    int end=n-1;

    for(int i=0;i<end;i++)

    {

        if(x>=a[end])

        {

            cnt++;

            x-=a[end];

            a[end]=0;

            end--;

        }

        

        if(a[i]>1)

        {

            cnt+=(a[i]/2);

            cnt+=1;

            a[i]=0;



        }

        else if(a[i]==1)

        {

            cnt++;

            x++;

            a[i]=0;



        }

    }

    if( a[end]>0 )

    {

        if(x>0)

        cnt++;

        a[end]-=x;

        // cnt++;

        if(a[end]>=1)

        {

            cnt+=(a[end]/2);

            cnt+=1;

            a[end]=0;



        }

        

    }

    if(cnt<=mid)

    return true;

    else

    return false;

}





bool isBitSet(int num, int bitPosition) {

    // Create a bit mask by shifting 1 to the left by bitPosition

    int mask = 1 << bitPosition;



    // Perform bitwise AND and check if the result is non-zero

    return (num & mask) != 0;

}

































long long f(int i,vector<int> &a,int n,vector<long long> &dp,long long &ans)

{

    if(i<0)

    {

        return 0;

    }

    // if(dp[i]!=-1)

    // return dp[i];

    long long pick=f(i-1,a,n,dp,ans);

    long long no=abs(a[i]+(pick));

    ans=max(ans,pick+a[i]);

    ans=max(ans,no);



    return dp[i]=(pick+a[i]);

}









void dfs(int i,map<int,vector<int>> &adj,vector<int> &vis,int c,int &ans)

{

    vis[i]=1;

    ans=max(ans,c);

    for(auto it:adj[c])

    {

        if(!vis[it])

        {

            dfs(it,adj,vis,c+1,ans);

        }

    }

}





bool f(long long n)

{

    while(n>0)

    {

        int r=n%10;

        if(r==7)

        return true;

        n=n/10;

    }

    return false;

}

int main() {

    int t;

    cin >> t;

    while (t--) 

    {

        

        long long n,l,r;

        cin>>n>>l>>r;

        long long k=r-l+1;

        vector<long long> a(n);

        for(long long i=0;i<n;i++)

        cin>>a[i];

        vector<long long> b;

        // vector<long long> b;

        vector<long long> c;

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

        long long ans=0;

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

        {

            b.push_back(a[i]);

        }

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

        {

            c.push_back(a[i]);

        }

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

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

        long long co=0;

        for(int i=0;i<k;i++)

        {

            co+=b[i];

        }ans=co;

        co=0;

        for(int i=0;i<k;i++)

        {

            co+=c[i];

        }

        ans=min(ans,co);

        cout<<ans<<endl;

        

        



       

    }

}