#P12554. [UOI 2024] Queries for Subarray Beauty
[UOI 2024] Queries for Subarray Beauty
题目描述
Let's call the weight of an array of integers of length the absolute value of the sum of its elements, i.e., .
We define the beauty of a partition of array into several subarrays as the minimum weight among the weights of the subarrays. Formally, the beauty of a partition of array into 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 , 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 into subarrays has a beauty of .
We define the beauty of an array as the maximum beauty among all possible partitions into subarrays.
An array of integers of length is given.
You need to perform queries. The queries can be of two types:
- find the beauty of the subarray consisting of elements , where (, ) are the query parameters;
- replace the element with , where (, ) are the query parameters.
输入格式
The first line contains two integers , () --- the length of array and the number of queries, respectively.
The second line contains integers ( --- the elements of array .
The next lines contain three integers each. The first of the numbers, (), denotes the type of the query. Queries of the first type are given in the format "" (), and queries of the second type are given in the format "" ( ).
输出格式
For each query of the first type, output a single integer --- the beauty of the corresponding subarray.
6 4
1 -3 4 2 -5 6
1 1 6
1 2 3
1 2 5
1 1 1
5
3
3
1
5 6
1 -2 3 -4 5
1 1 4
1 2 3
2 3 -6
1 2 4
2 4 2
1 1 5
2
2
12
7
提示
In the first example, for the third query, the maximum beauty of the partition of the array is achieved when partitioned into subarrays .
In the second example, for the first query, the maximum beauty of the partition of the array is achieved when partitioned into subarrays .
Scoring
- ( points): for ; for ;
- ( points): for ; ;
- ( points): for ; , for each query there exists an optimal division into no more than subarrays;
- ( points): for ; , , for ;
- ( points): for ; , for ;
- ( points): for ; ;
- ( points): for ;
- ( points): ;
- ( points): without additional constraints.