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

Code 1:
// Handle: akhilpranjal

// Date: 05-02-2025

// Time: 17:12

 

#include<bits/stdc++.h>

using namespace std;

 

#define rep(i,a,b) for (int i=a;i<b;i++)

#define vll vector<long long>

#define ll long long

#define ull unsigned long long

#define ld long double

#define F first

#define S second

#define all(x) (x).begin(),(x).end()

#define rall(x) (x).rbegin(),(x).rend()

 

// Operator Overloads:

 

template<typename T1, typename T2>     // cin >> pair<T1,T2>

istream& operator>>(istream &istream, pair<T1,T2> &p) { return (istream >> p.first >> p.second); }

 

template<typename T>     // cin >> vector<T> &v

istream& operator>>(istream &istream, vector<T> &v)

{

    for(auto &it : v)

    {

        cin >> it;

    }

    return istream;

}

 

template<typename T1, typename T2>     // cout << pair<T1,T2>

ostream& operator<<(ostream &ostream, const pair<T1,T2> &p) { return(ostream << p.first << " " << p.second); }

 

template<typename T>     // cout << vector<T>

ostream& operator<<(ostream &ostream, const vector<T> &v) { for (auto &it : v) cout << it << " "; return ostream; }

 

 

 

void solve()

{

    ll n,l,r,sum1=0,sum2=0;

    cin>>n>>l>>r;

    l--;r--;

    vll a(n),b;

    cin>>a;

    b=a;

    // ll x = r-l+1;

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

    rep(i,0,r-l+1)

    {

        sum1 += a[i];

    }

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

    rep(i,l,r+1)

    {

        sum2 += b[i];

    }

    cout<<min(sum1,sum2);



    

    



}

 

 

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

 

    ll t;

    cin >> t;

    for(int i=1;i<=t;i++) {

        solve();

        cout<<endl;

    }

    return 0;

}

Code 2:
// Handle: akhilpranjal

// Date: 05-02-2025

// Time: 17:12

 

#include<bits/stdc++.h>

using namespace std;

 

#define rep(i,a,b) for (int i=a;i<b;i++)

#define vll vector<long long>

#define ll long long

#define ull unsigned long long

#define ld long double

#define F first

#define S second

#define all(x) (x).begin(),(x).end()

#define rall(x) (x).rbegin(),(x).rend()

 

// Operator Overloads:

 

template<typename T1, typename T2>     // cin >> pair<T1,T2>

istream& operator>>(istream &istream, pair<T1,T2> &p) { return (istream >> p.first >> p.second); }

 

template<typename T>     // cin >> vector<T> &v

istream& operator>>(istream &istream, vector<T> &v)

{

    for(auto &it : v)

    {

        cin >> it;

    }

    return istream;

}

 

template<typename T1, typename T2>     // cout << pair<T1,T2>

ostream& operator<<(ostream &ostream, const pair<T1,T2> &p) { return(ostream << p.first << " " << p.second); }

 

template<typename T>     // cout << vector<T>

ostream& operator<<(ostream &ostream, const vector<T> &v) { for (auto &it : v) cout << it << " "; return ostream; }

 

 

 

void solve()

{

    ll n,l,r,sum=0;

    cin>>n>>l>>r;

    vll a(n);

    cin>>a;

    sort(all(a));

    rep(i,0,r-l+1)

    {

        sum +=a[i];

    }

    cout<<sum;



}

 

 

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

 

    ll t;

    cin >> t;

    for(int i=1;i<=t;i++) {

        solve();

        cout<<endl;

    }

    return 0;

}

Answer: 1