#C7333. Minimum in Subarray

    ID: 51193 Type: Default 1000ms 256MiB

Minimum in Subarray

Minimum in Subarray

You are given an array of n integers and q queries. Each query consists of two integers l and r (1-indexed) specifying a subarray. Your task is to compute the minimum element in each subarray.

For a query with indices \(l\) and \(r\), you need to find: \[ \min\{A_l, A_{l+1}, \dots, A_r\} \]

Read the input from standard input and output the answer for each query on a new line.

inputFormat

The input is provided from standard input in the following format:

  1. The first line contains an integer (n), the number of elements in the array.
  2. The second line contains (n) space-separated integers representing the array (A).
  3. The third line contains an integer (q), the number of queries.
  4. Each of the next (q) lines contains two space-separated integers, (l) and (r), representing the bounds of a query (1-indexed).

outputFormat

For each query, output a single integer — the minimum element found in the subarray from index (l) to (r) (inclusive). Each answer should be printed on a new line.## sample

5
4 2 5 3 1
3
1 3
2 5
3 3
2

1 5

</p>