영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
There are n buildings on a street, numbered 1,2,…,n. Each building has a pizzeria and an apartment.
The pizza price in building k is p_k. If you order a pizza from building a to building b, its price (with delivery) is p_a+|a-b|.
Your task is to process two types of queries:
- The pizza price p_k in building k becomes x.
- You are in building k and want to order a pizza. What is the minimum price?
Input
The first input line has two integers n and q: the number of buildings and queries.
The second line has n integers p_1,p_2,…,p_n: the initial pizza price in each building.
Finally, there are q lines that describe the queries. Each line is either "1 k x" or "2 k".
Output
Print the answer for each query of type 2.
Constraints
- 1 ≤ n,q ≤ 2 · 10^5
- 1 ≤ p_i, x ≤ 10^9
- 1 ≤ k ≤ n
예제
예제 1
6 3 8 6 4 5 7 5 2 2 1 5 1 2 2
5 4