Codeforces Round 670 (Div. 2) |
---|
Finished |
You are given a sequence of $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$.
You have to construct two sequences of integers $$$b$$$ and $$$c$$$ with length $$$n$$$ that satisfy:
You have to minimize $$$\max(b_i,c_i)$$$. In other words, you have to minimize the maximum number in sequences $$$b$$$ and $$$c$$$.
Also there will be $$$q$$$ changes, the $$$i$$$-th change is described by three integers $$$l,r,x$$$. You should add $$$x$$$ to $$$a_l,a_{l+1}, \ldots, a_r$$$.
You have to find the minimum possible value of $$$\max(b_i,c_i)$$$ for the initial sequence and for sequence after each change.
The first line contains an integer $$$n$$$ ($$$1\leq n\leq 10^5$$$).
The secound line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1\leq i\leq n$$$, $$$-10^9\leq a_i\leq 10^9$$$).
The third line contains an integer $$$q$$$ ($$$1\leq q\leq 10^5$$$).
Each of the next $$$q$$$ lines contains three integers $$$l,r,x$$$ ($$$1\leq l\leq r\leq n,-10^9\leq x\leq 10^9$$$), desribing the next change.
Print $$$q+1$$$ lines.
On the $$$i$$$-th ($$$1 \leq i \leq q+1$$$) line, print the answer to the problem for the sequence after $$$i-1$$$ changes.
4 2 -1 7 3 2 2 4 -3 3 4 2
5 5 6
6 -9 -10 -9 -6 -5 4 3 2 6 -9 1 2 -10 4 6 -3
3 3 3 1
1 0 2 1 1 -1 1 1 -1
0 0 -1
In the first test:
Name |
---|