#SGM0000002. Truy vấn giá trị nhỏ nhất động (Dynamic Range Minimum Queries)
Truy vấn giá trị nhỏ nhất động (Dynamic Range Minimum Queries)
Dynamic Range Minimum Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of integers and operations. Each operation either assigns a new value to one position or asks for the minimum value on a contiguous range.
Input
- The first line contains two integers and .
- The second line contains integers .
- Each of the next lines is either
1 k u, which sets , or2 a b, which asks for the minimum among .
Output
For every operation of type 2, print the requested minimum value on its own line.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
8 4
3 2 4 5 1 1 5 3
2 1 4
2 5 6
1 2 3
2 1 4
Output
2
1
3
Explanation
Initially, the minimum on is , and on it is . After 1 2 3, the range becomes , so its minimum is .