View Code of Problem 134


import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
            }
            int q = scanner.nextInt();
            for (int i = 0; i < q; i++) {
                int l = scanner.nextInt();
                int r = scanner.nextInt();
                int temp[] = new int[r - l + 1];
                System.arraycopy(a,l-1,temp,0,r-l+1);
                Arrays.sort(temp);
                System.out.println(temp[0]);
            }
        }
    }
}

Double click to view unformatted code.


Back to problem 134