链接:
https://ac.nowcoder.com/acm/contest/57362/C
来源:牛客网
For an integer sequence
a1,a2,…,ana_1, a_2, \ldots, a_na1,a2,…,an and a positive integer
ddd, the
ddd-clamped value of the sequence is the maximum value of
∑i=1n−1∑j=i+1n∣ai−aj∣\sum_{i=1}^{n-1}\sum_{j=i+1}^{n}|a_i - a_j|∑i=1n−1∑j=i+1n∣ai−aj∣, where
∣x∣|x|∣x∣ is the absolute value of
xxx, after appointing a range
[l,r][l,r][l,r] satisfying
0≤r−l≤d0 \le r-l \le d0≤r−l≤d and clamping the sequence to the range
[l,r][l, r][l,r].
More specifically, clamping the sequence to the range
[l,r][l,r][l,r] makes each element
Both
lll and
rrr are arbitrary real numbers decided by you under the given constraints. It can be shown that the maximum sum is always an integer.
Now, given an integer sequence
a1,a2,…,ana_1, a_2, \ldots, a_na1,a2,…,an and
qqq queries, where each query is in one of the two following formats:
-
111 xxx ddd denotes setting axa_xax to ddd
-
222 ddd denotes reporting the d-clamped value of the current sequence
Please output the answer for each reporting queries.