PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000003. Truy vấn giá trị nhỏ nhất trên đoạn tĩnh (Static Range Minimum Queries)
HỌC THEO LỘ TRÌNH
3 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vấn giá trị nhỏ nhất trên đoạn tĩnh (Static Range Minimum Queries)
Static Range Minimum Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of integers and queries, find the minimum value within each inclusive interval . The array remains unchanged. If the minimum occurs several times, print its value only.
Input
The first line contains , followed by a line with integers . Each of the following lines contains for an inclusive range-minimum query.
Output
For each query requesting a result, output one integer on its own line in input order. Update operations produce no output.
Subtasks
- Subtask 1 (20 points): ; ; for every query and for all .
- Subtask 2 (25 points): ; ; for every query and for all .
- Subtask 3 (55 points): ; ; for every query and for all .
Examples
Input
8 4
3 2 4 5 1 1 5 3
2 4
5 6
1 8
3 3
Output
2
1
1
4
Explanation
The minimum in is , in it is , and in the entire array it is . The single-element range has minimum .