#C3329. Minimum in Subarrays

    ID: 46744 Type: Default 1000ms 256MiB

Minimum in Subarrays

Minimum in Subarrays

You are given an array of integers and a list of queries. Each query is represented by two integers (L) and (R) (0-indexed) that denote the start and end indices of a subarray. Your task is to determine the minimum value within the subarray from index (L) to (R) (inclusive).

For example, given the array [5, 2, 4, 7, 1, 3, 6, 8] and a query (0, 4), the subarray is [5, 2, 4, 7, 1] and the minimum value is 1.

This problem requires efficient handling of range minimum queries.

inputFormat

The input is given in the following format:
(n): an integer representing the number of elements in the array.
Next line contains (n) space-separated integers representing the array.
(q): an integer denoting the number of queries.
The next (q) lines each contain two space-separated integers (L) and (R) (0-indexed), representing a query.

outputFormat

For each query, output the minimum value in the subarray defined by indices (L) and (R). Each result should be printed on a new line.## sample

8
5 2 4 7 1 3 6 8
5
0 4
3 6
1 5
2 2
3 7
1

1 1 4 1

</p>