#P6011. [SCOI2006] 动态最值

[SCOI2006] 动态最值

Problem Description

You are given an array containing nn elements. You need to support the following operations:

  • DELETE k: Delete the number at position kk. All numbers to the right shift one position to the left.
  • QUERY i j: Query the minimum and maximum values among all numbers in positions iji \sim j.

For example, there are 1010 elements:

Position 11 22 33 44 55 66 77 88 99 1010
Element 11 55 22 66 77 44 99 33 11 55

The result of QUERY 2 8 is 2 9. After performing DELETE 3 and then DELETE 6 (note that this deletes the element 77 from the original array), the array becomes:

Position 11 22 33 44 55 66 77 88
Element 11 55 66 77 44 33 11 55

The result of QUERY 2 8 is 1 7.

Input Format

The first line contains two integers n,mn, m, representing the number of elements in the original array and the number of operations.
The second line contains nn integers, representing the original array.
The next mm lines each describe an operation in the form 1 k or 2 i j, where the first number is 11 for a delete operation, and 22 for a query operation.

Output Format

For each query operation, output one line containing two integers: the minimum value and the maximum value in that range.

10 4
1 5 2 6 7 4 9 3 1 5
2 2 8
1 3
1 6
2 2 8
2 9
1 7

Hint

For 50%50\% of the testdata, 1n,m1041 \le n, m \le {10}^4, and there are no more than 100100 delete operations.
For 100%100\% of the testdata, 1n,m1061 \le n, m \le {10}^6, and the absolute value of each array element does not exceed 109{10}^9.

Translated by ChatGPT 5