PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#LCA0000039. Truy vấn nhỏ nhất theo chỉ số 0 (Range Minimum Query)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vấn nhỏ nhất theo chỉ số 0 (Range Minimum Query)
Range Minimum Query
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a static list of integers indexed from to . For each of queries, return the smallest value on the closed interval .
The array never changes. If , the answer equals .
Input
- First line: .
- Next line: .
- Next line: .
- Last lines: with .
Output
Print one minimum per query.
Subtasks
General constraints (all subtasks): ; ; ; each fits in a signed 32-bit integer.
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3
1 4 1
2
1 1
1 2
Output
4
1
Explanation
Range contains only ; range contains and has minimum .