#C7333. Minimum in Subarray
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:
- The first line contains an integer (n), the number of elements in the array.
- The second line contains (n) space-separated integers representing the array (A).
- The third line contains an integer (q), the number of queries.
- 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>