| antontrygubO_o UOI problems |
|---|
| Закончено |
Let's call the weight of an array of integers $$$b$$$ of length $$$m$$$ the absolute value of the sum of its elements, i.e., $$$|b_1+b_2+...+b_m|$$$.
We define the beauty of a partition of array $$$c$$$ into several subarrays as the minimum weight among the weights of the subarrays. Formally, the beauty of a partition of array $$$c$$$ into $$$k$$$ subarrays $$$[c_1,\ldots,c_{p_1}],[c_{p_1+1},\ldots,c_{p_2}],\ldots,[c_{p_{k-1}+1},\ldots,c_{p_k}]$$$, where $$$1 \leq p_1 \lt p_2 \lt \ldots \lt p_{k-1} \lt p_k = n$$$, is the value $$$\min(|c_1+\ldots+c_{p_1}|,|c_{p_1+1}+\ldots+c_{p_2}|,\ldots,|c_{p_{k-1}+1}+\ldots+c_{p_k}|)$$$. For example, the partition of the array $$$[3,-6,4,5,-8]$$$ into subarrays $$$[3,-6],[4],[5,-8]$$$ has a beauty of $$$\min(|3+(-6)|,|4|,|5+(-8)|)=\min(3,4,3)=3$$$.
We define the beauty of an array $$$c$$$ as the maximum beauty among all possible partitions into subarrays.
An array of integers $$$a$$$ of length $$$n$$$ is given.
You need to perform $$$q$$$ queries. The queries can be of two types:
The first line contains two integers $$$n$$$, $$$q$$$ ($$$1\le n, q\le 10^6$$$) — the length of array $$$a$$$ and the number of queries, respectively.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^9\le a_i\le 10^9)$$$ — the elements of array $$$a$$$.
The next $$$q$$$ lines contain three integers each. The first of the numbers, $$$type_i$$$ ($$$1 \le type_i \le 2$$$), denotes the type of the query. Queries of the first type are given in the format "1 l r" ($$$1\le l\le r\le n$$$), and queries of the second type are given in the format "2 x v" ($$$1\le x\le n,$$$ $$$-10^9\le v\le 10^9$$$).
For each query of the first type, output a single integer — the beauty of the corresponding subarray.
6 41 -3 4 2 -5 61 1 61 2 31 2 51 1 1
5 3 3 1
5 61 -2 3 -4 51 1 41 2 32 3 -61 2 42 4 21 1 5
2 2 12 7
In the first example, for the third query, the maximum beauty of the partition of the array $$$[-3,4,2,-5]$$$ is achieved when partitioned into subarrays $$$[-3],[4,2],[-5]$$$.
In the second example, for the first query, the maximum beauty of the partition of the array $$$[1,-2,3,-4]$$$ is achieved when partitioned into subarrays $$$[1,-2,3],[-4]$$$.
| Название |
|---|


