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

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>

#define log(x) cout << x << "\n"

using namespace std;
int n;
int l;
int r;
int t;
void reversesub(int a[],int l,int r);
long long sumvec(vector<int> v, int stop);

int main(){
        cin >> t;
        while ( t > 0){
                cin >> n >> l >> r;
                int a[n];
                for (int i= 0; i < n; i++){
                        cin >> a[i];
                }
                l--;
                vector<int> b(r, 0);

                //cout << "size: " << b.size() << " b: \n";
                for(int i = 0; i < b.size(); i++){
                        //cout << "i: " << i << ", b[i]: ";
                        b[i] = a[i];
                        //cout << b[i] << "\n";
                }
                //cout << "\n";
                long long minsum = (int)1E18;
                if (!b.empty()){
                        sort(b.begin(), b.end());
                        minsum = min(minsum, sumvec(b, r-l));
                        //cout << "s1: " << sumvec(b, r-l) << "\n";
                }
                
                vector<int> c(n-l, 0);
                //cout << "size: " << c.size() <<", c: \n";
                for(int i = 0; i < c.size(); i++){
                        c[i] = a[l+i];
                        //cout <<"i: "<< i << "c[i]: " << c[i] << "\n";
                }
                //cout << "\n";
                
                if(!c.empty()){
                        sort(c.begin(), c.end());
                        minsum = min(minsum, sumvec(c, r-l));
                        //cout << "s2: " << sumvec(c, r-l) << "\n";
                }
                
                t--;
                cout << minsum << "\n";
        }
        

        return 0;
}

long long sumvec(vector<int> v, int stop){
        long long sum = 0;
        for(int i = 0;i < stop; i++){
                sum += v[i];
        }
        return sum;
}

      

Submission (verdict: Accepted):
#include <bits/stdc++.h>

#define log(x) cout << x << "\n"

using namespace std;
int n;
int l;
int r;
int t;
void reversesub(int a[],int l,int r);
long long sumvec(vector<int> v, int stop);

int main(){
        cin >> t;
        while ( t > 0){
                cin >> n >> l >> r;
                int a[n];
                for (int i= 0; i < n; i++){
                        cin >> a[i];
                }
                l--;
                vector<int> b(r, 0);

                //cout << "size: " << b.size() << " b: \n";
                for(int i = 0; i < b.size(); i++){
                        //cout << "i: " << i << ", b[i]: ";
                        b[i] = a[i];
                        //cout << b[i] << "\n";
                }
                //cout << "\n";
                long long minsum = (long long)1E18;
                if (!b.empty()){
                        sort(b.begin(), b.end());
                        minsum = min(minsum, sumvec(b, r-l));
                        //cout << "s1: " << sumvec(b, r-l) << "\n";
                }
                
                vector<int> c(n-l, 0);
                //cout << "size: " << c.size() <<", c: \n";
                for(int i = 0; i < c.size(); i++){
                        c[i] = a[l+i];
                        //cout <<"i: "<< i << "c[i]: " << c[i] << "\n";
                }
                //cout << "\n";
                
                if(!c.empty()){
                        sort(c.begin(), c.end());
                        minsum = min(minsum, sumvec(c, r-l));
                        //cout << "s2: " << sumvec(c, r-l) << "\n";
                }
                
                t--;
                cout << minsum << "\n";
        }
        

        return 0;
}

long long sumvec(vector<int> v, int stop){
        long long sum = 0;
        for(int i = 0;i < stop; i++){
                sum += v[i];
        }
        return sum;
}