Problem: 2063B - Subsequence Update
Language: java

Solution 1 (runtime: 593 ms):
import java.util.*;

public final class F1{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- != 0){
			int n = sc.nextInt();
			int l = sc.nextInt();
			int r = sc.nextInt();
			int[] arr = new int[n];
			int[] left = new int[r];
			int[] right = new int[n-l+1];
			for(int i = 0; i < arr.length; i++){
				arr[i] = sc.nextInt();
			}
			for(int i = 0; i < left.length; i++){
				left[i] = arr[i];
			}
			for(int i = 0; i < right.length; i++){
				right[i] = arr[l-1+i];
			}
			Arrays.sort(left);
			Arrays.sort(right);
			long sum1 = 0;
			long sum2 = 0; 
			for(int i = 0 ; i <= r - l; i++){
				sum1 += (long)left[i];
				sum2 += (long)right[i];
			}
			System.out.println(Math.min(sum1, sum2));
		}
	}		
}

Solution 2 (runtime: 281 ms):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
// import java.math.BigInteger;
import java.util.*;

public class Yuv1 {

    public static boolean isPrime(int n) {
        if (n <= 1) {
            return false;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    // GCD
    public static long gcd(long a, long b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }

    // Fast Input
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(
                    new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                if (st.hasMoreTokens()) {
                    str = st.nextToken("\n");
                } else {
                    str = br.readLine();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long factorial(long n) {
        long f = 1;
        for (int i = 2; i <= n; i++)
            f *= i;
        return f;
    }

    public static long countDigitsInFact(long n) {

        if (n == 0 || n == 1) {
            return 1;
        }
        double logSum = 0;
        for (int i = 2; i <= n; i++) {
            logSum += Math.log10(i);
        }

        return (long) Math.floor(logSum) + 1;
    }
    private static void reverse(long[] arr, int start, int end) {
        while (start < end) {
            long temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end--;
        }
    }

    private static long sumSubarray(long[] arr, int start, int end) {
        long sum = 0;
        for (int i = start; i <= end; i++) {
            sum += arr[i];
        }
        return sum;
    }

    public static int mod = 1000000007;
    static final long NEG_INF = -1000000000000000L;
    static final long INF = 1000000000000000L;

    public static void main(String args[]) {
        FastReader x = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = x.nextInt();

        while (t-- > 0) {

            int n = x.nextInt();
            int l = x.nextInt();
            int r = x.nextInt();
            l--;
            long[] a = new long[n];
            for(int i=0;i<n;i++) {
                a[i]=x.nextLong();
            }

            long[] b = Arrays.copyOf(a, n);
            Arrays.sort(b, 0, r);
            reverse(b, 0, r-1);
            Arrays.sort(a, l, n);

            System.out.println(Math.min(sumSubarray(a, l, r-1), sumSubarray(b, l, r-1)));
        }
        out.flush();
    }
}