CF739C.Alyona and towers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alyona has built nn towers by putting small cubes some on the top of others. Each cube has size 1×1×11×1×1 . A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.

Sometimes Alyona chooses some segment towers, and put on the top of each tower several cubes. Formally, Alyouna chooses some segment of towers from lil_{i} to rir_{i} and adds did_{i} cubes on the top of them.

Let the sequence a1,a2,...,ana_{1},a_{2},...,a_{n} be the heights of the towers from left to right. Let's call as a segment of towers al,al+1,...,ara_{l},a_{l+1},...,a_{r} a hill if the following condition holds: there is integer kk ( l<=k<=rl<=k<=r ) such that a_{l}<a_{l+1}<a_{l+2}<...<a_{k}>a_{k+1}>a_{k+2}>...>a_{r} .

After each addition of did_{i} cubes on the top of the towers from lil_{i} to rir_{i} , Alyona wants to know the maximum width among all hills. The width of a hill is the number of towers in it.

输入格式

The first line contain single integer nn ( 1<=n<=31051<=n<=3·10^{5} ) — the number of towers.

The second line contain nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ) — the number of cubes in each tower.

The third line contain single integer mm ( 1<=m<=31051<=m<=3·10^{5} ) — the number of additions.

The next mm lines contain 33 integers each. The ii -th of these lines contains integers lil_{i} , rir_{i} and did_{i} ( 1<=l<=r<=n1<=l<=r<=n , 1<=di<=1091<=d_{i}<=10^{9} ), that mean that Alyona puts did_{i} cubes on the tio of each of the towers from lil_{i} to rir_{i} .

输出格式

Print mm lines. In ii -th line print the maximum width of the hills after the ii -th addition.

输入输出样例

  • 输入#1

    5
    5 5 5 5 5
    3
    1 3 2
    2 2 1
    4 4 1
    

    输出#1

    2
    4
    5
    

说明/提示

The first sample is as follows:

After addition of 22 cubes on the top of each towers from the first to the third, the number of cubes in the towers become equal to [7,7,7,5,5][7,7,7,5,5] . The hill with maximum width is [7,5][7,5] , thus the maximum width is 22 .

After addition of 11 cube on the second tower, the number of cubes in the towers become equal to [7,8,7,5,5][7,8,7,5,5] . The hill with maximum width is now [7,8,7,5][7,8,7,5] , thus the maximum width is 44 .

After addition of 11 cube on the fourth tower, the number of cubes in the towers become equal to [7,8,7,6,5][7,8,7,6,5] . The hill with maximum width is now [7,8,7,6,5][7,8,7,6,5] , thus the maximum width is 55 .

首页