Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
/* 

    author: Aditya Gupta 

    created: 05.02.2025 15:42:59

*/



#include <bits/stdc++.h>

using namespace std;



#ifndef ONLINE_JUDGE

// Template to debug 1 variable

template<typename T>

void debug1(const char* varName, T varValue) {

    cout << varName << " = " << varValue << endl;

}

// Template to debug 2 variables

template<typename T1, typename T2>

void debug2(const char* varName1, T1 varValue1, const char* varName2, T2 varValue2) {

    cout << varName1 << " = " << varValue1 << " " << varName2 << " = " << varValue2 << endl;

}

// Template to print a vector

template<typename T>

void debug_vector(const char* varName, const vector<T>& vec) {

    cout << varName << " = [";

    for (size_t i = 0; i < vec.size(); ++i) {

        cout << vec[i];

        if (i < vec.size() - 1) cout << ", ";

    }

    cout << "]" << endl;

}



#define debug1(var) debug1(#var, var)

#define debug2(var1, var2) debug2(#var1, var1, #var2, var2)

#define debug_vector(vec) debug_vector(#vec, vec)



#else

#define debug1(var)

#define debug2(var1, var2)

#define debug_vector(vec)

#endif



#define int long long



void solve(){

   int n,l,r;

   cin>>n>>l>>r;

   vector<int> arr(n);

   for(auto &it: arr) cin>>it;

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

   int sum=0,i=0;

   while(i<=(r-l)){

        sum+=arr[i];

        i++;

   }

   cout<<sum<<endl;

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    auto start = chrono::high_resolution_clock::now();



    int t;

    cin >> t;

    

    while (t--) {

        solve();

    }



    auto end = chrono::high_resolution_clock::now();

    auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);

    cerr << "Execution Time: " << duration.count() << " ms" << std::endl;



    return 0;

}

Submission (verdict: Wrong answer on test 8):
/* 

    author: Aditya Gupta 

    created: 05.02.2025 15:42:59

*/



#include <bits/stdc++.h>

using namespace std;



#ifndef ONLINE_JUDGE

// Template to debug 1 variable

template<typename T>

void debug1(const char* varName, T varValue) {

    cout << varName << " = " << varValue << endl;

}

// Template to debug 2 variables

template<typename T1, typename T2>

void debug2(const char* varName1, T1 varValue1, const char* varName2, T2 varValue2) {

    cout << varName1 << " = " << varValue1 << " " << varName2 << " = " << varValue2 << endl;

}

// Template to print a vector

template<typename T>

void debug_vector(const char* varName, const vector<T>& vec) {

    cout << varName << " = [";

    for (size_t i = 0; i < vec.size(); ++i) {

        cout << vec[i];

        if (i < vec.size() - 1) cout << ", ";

    }

    cout << "]" << endl;

}



#define debug1(var) debug1(#var, var)

#define debug2(var1, var2) debug2(#var1, var1, #var2, var2)

#define debug_vector(vec) debug_vector(#vec, vec)



#else

#define debug1(var)

#define debug2(var1, var2)

#define debug_vector(vec)

#endif



#define int long long





void solve() {

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n);

    for (auto &it : arr) cin >> it;



    vector<int> a = arr, b = arr;



    sort(a.begin(), a.begin() + r,greater<int>());         

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



    int s1 = accumulate(a.begin() + l - 1, a.begin() + r, 0);

    int s2 = accumulate(b.begin() + l - 1, b.begin() + r, 0);



    cout << min(s1, s2) << endl;

}

signed main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    auto start = chrono::high_resolution_clock::now();



    int t;

    cin >> t;

    

    while (t--) {

        solve();

    }



    auto end = chrono::high_resolution_clock::now();

    auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);

    cerr << "Execution Time: " << duration.count() << " ms" << std::endl;



    return 0;

}