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


Submission (verdict: Wrong answer on test 8):
//DIVYANKAR SHAH//
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define N 1000000
#define MOD 1000000007
#define pb push_back
#define SORT(v) sort(v.begin(), v.end())
#define count_setBits __builtin_popcount
#define count_setBitsll __builtin_popcountll
vector<bool> sieve(N+1);
vector<int> spf(N+1);

//----------------INPUT/OUTPUT--------------//
void input(ll n,vector<ll>&a){
    for(int i=0; i<n; i++) cin>>a[i];
}

void debug(vector<ll>&a){
    cout<<"[ ";
    for(int i=0; i<a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<"]"<<'\n';
}
//-----------------------------------------//


//------------BIT-TECH--------------------//
//check if a number is even/odd
bool isEven(int x){
    if(x&1) return false;
    return true;
}

//check power of 2 or not
bool powerOf2(int x){
    return (x && (!(x&(x-1))));
}

//kth bit is set or not
bool isKthBitSet(int x, int k){
    if((x&(1<<k))) return true;
    return false;
}

//Toggle Kth bit
void toggleKthBit(int x, int k){
    x = (x^(1<<k));
}

//unset the kth bit
void unsetKthBit(int x, int k){
    x = (x & (~(1<<k)));
}

//set kth bit
void setKthBit(int x, int k){
    x = (x | (1<<k));
}
//--------------------------------------//


//--------------------NUMBER-THEORY-----------------------//
//lcm
ll lcm(ll a,ll b){
    ll g=__gcd(a,b);
    return (a*b/g);
}

//binary exponentiation (a^b)%m
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//sieve creation
void createSieve(){
    for(int i=2; i<=N; i++){
        sieve[i]=true;
    }

    for(int i=2; i*i<=N; i++){
        if(sieve[i]){
            for(int j=i*i; j<=N; j+=i){
                sieve[j]=false;
            }
        }
    }
}

//sieve for prime
void sieveForPrimeFactors(){
    for(int i=2; i<=N; i++){
        spf[i]=i;
    }

    for(int i=2; i*i<=N; i++){
        if(spf[i]==i){
            for(int j=i*i; j<=N; j+=i){
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}

//prime factorization
vector<int> primeFactors(int n){
    vector<int> result;
    while(n>1){
        result.push_back(spf[n]);
        n/=spf[n];
    }
    if(n>1) result.push_back(n);
    return result;
}

//finding divisors of a number (1<=number<=1e9)
vector<int> findDivisors(int n){
    vector<int> divisors;
    for(int i=2; i*i<=n; i++){
        if(n%i==0){
            divisors.push_back(i);
            if(n/i!=i){
                divisors.push_back(n/i);
            }
        }
    }

    return divisors;
}
//----------------------------------------------------//


//-------------------STRING----------------------------//
//checking for a substring in a string
int isSubstringPresent(string substr, string &s){
    if(s.find(substr)!=string::npos){
        return s.find(substr); //returning the starting index of substr in s.
    }
    return -1;
}

// calculation of Z arr
// Z[i] = length of the longest substring starting from i which is also a prefix of s
vector<int> z_function(string s){
    int n = s.size();
    vector<int> z(n,0);
    int left = 0, right = 0;
    for(int i=1; i<n; i++){
        if(i>right){
            left = right = i;
            while(right<n && s[right]==s[right-left]){
                right++;
            }
            z[i] = right-left;
            right--;
        }
        else{
            int k = i-left;
            if(z[k]<right-i+1){
                z[i] = z[k];
            }
            else{
                left = i;
                while(right<n && s[right]==s[right-left]){
                    right++;
                }
                z[i] = right-left;
                right--;
            }
        }
    }
    return z;
}

// LPS array
// LPS[i] = length of the longest proper prefix which is also a suffix of s[0...i]
vector<int> compute_lps(string s){
    int n = s.size();
    vector<int> lps(n,0);
    int len = 0;
    lps[0] = 0;
    int i = 1;
    while(i<n){
        if(s[i]==s[len]){
            len++;
            lps[i] = len;
            i++;
        }
        else{
            if(len!=0){
                len = lps[len-1];
            }
            else{
                lps[i] = 0;
                i++;
            }
        }
    }
    return lps;
}

// KMP algorithm
// returns the starting index of the substring in the string
int KMP(string &txt, string &pat){
    int n = txt.size();
    int m = pat.size();
    vector<int> lps = compute_lps(pat);
    int i = 0, j = 0;
    while(i<n){
        if(txt[i]==pat[j]){
            i++;
            j++;
        }
        if(j==m){
            return i-j;
        }
        else if(i<n && txt[i]!=pat[j]){
            if(j!=0){
                j = lps[j-1];
            }
            else{
                i++;
            }
        }
    }
    return -1;
}
//-----------------------------------------------------//

bool allEqual(vector<ll>&v){
    if(equal(v.begin() + 1, v.end(), v.begin())) return true;
    return false;
}

// Points To Remember:
// 1. Think Greedy
// 2. Think Brute Force
// 3. Think solution in reverse order
// 4. Think DP [ check constraints carefully ]
// 5. Check base cases for DP and prove solution for Greedy
// 6. Think Graph
// 7. ceil a/b=(a+b-1)/b do remember
// 8. Remember to convert size() to int!! Causes creji errors!
// 9. XOR is invertible to itself.
// 10. If x = a mod b then a mod 2b = x or x+a
// 11. (a+b)modc = (a+b-c)modc

void solve(){
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    l--, r--;
    vector<int> temp1(a.begin(), a.begin()+r+1); // 0 to r
    vector<int> temp2(a.begin()+l, a.end()); // l to n-1
    sort(temp1.begin(), temp1.end());
    sort(temp2.begin(), temp2.end());
    int ans1 = accumulate(temp1.begin(), temp1.begin()+r-l+1, 0); // sum of r-l+1 elements
    int ans2 = accumulate(temp2.begin(), temp2.begin()+r-l+1, 0); // sum of r-l+1 elements
    cout << min(ans1, ans2) << '\n';
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int t;
    cin>>t;
    while(t--){
        solve();
    }

    return 0;
}