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

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;

long long min(long long a, long long b, long long c)

{

    return min(a, min(b, c));

}

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        int n, l, r;

        cin >> n >> l >> r;

        int a[100005] = {0};

        long long s[100005] = {0};

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

            cin >> a[i];

        sort(a + r, a + n);

        sort(a, a + l - 1); // [a, b)

        sort(a + l - 1, a + r, greater<int>());

        // for (int i = 0; i < n; i++)

        //     cout << a[i] << " ";

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

        {

            s[i] = a[i];

            if (i > 0)

                s[i] += s[i - 1];

        }

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

        {

            s[i] = a[i];

            if (i > l - 1)

                s[i] += s[i - 1];

        }

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

        {

            s[i] = a[i];

            if (i > r)

                s[i] += s[i - 1];

        }

        // cout << "\n";

        // for (int i = 0; i < n; i++)

        //     cout << s[i] << " ";

        long long ans = s[r-1];

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

        {

            int ll = i - l + 1;

            int rr = r+ll;

            long long now = s[r - 1] - s[i];

            ans = min(ans, (ll >= l - 1? 999999999 : now + s[ll]),(rr < n ? now + s[rr] : 999999999));

        }

        // cout << "\n";

        cout << ans << "\n";

    }

}

Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;

long long min(long long a, long long b, long long c)

{

    return min(a, min(b, c));

}

int main()

{

    int t;

    cin >> t;

    while (t--)

    {

        int n, l, r;

        cin >> n >> l >> r;

        int a[100005] = {0};

        long long s[100005] = {0};

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

            cin >> a[i];

        sort(a + r, a + n);

        sort(a, a + l - 1); // [a, b)

        sort(a + l - 1, a + r, greater<int>());

        // for (int i = 0; i < n; i++)

        //     cout << a[i] << " ";

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

        {

            s[i] = a[i];

            if (i > 0)

                s[i] += s[i - 1];

        }

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

        {

            s[i] = a[i];

            if (i > l - 1)

                s[i] += s[i - 1];

        }

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

        {

            s[i] = a[i];

            if (i > r)

                s[i] += s[i - 1];

        }

        // cout << "\n";

        // for (int i = 0; i < n; i++)

        //     cout << s[i] << " ";

        long long ans = s[r-1];

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

        {

            int ll = i - l + 1;

            int rr = r+ll;

            long long now = s[r - 1] - s[i];

            ans = min(ans, (ll >= l - 1? 999999999999 : now + s[ll]),(rr < n ? now + s[rr] : 999999999999));

        }

        // cout << "\n";

        cout << ans << "\n";

    }

}