Codeforces Round 381 (Div. 1)
C
Alyona and towers
Codeforces
2500
原题
← BD →
翻译中…

Alyona has built $*n*$ towers by putting small cubes some on the top of others. Each cube has size $1 × 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 $*l*_{*i*}$ to $*r*_{*i*}$ and adds $*d*_{*i*}$ cubes on the top of them.

翻译中…

Let the sequence $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ be the heights of the towers from left to right. Let's call as a segment of towers $*a*_{*l*}, *a*_{*l* + 1}, ..., *a*_{*r*}$ a hill if the following condition holds: there is integer $*k*$ ($*l* ≤ *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 $*d*_{*i*}$ cubes on the top of the towers from $*l*_{*i*}$ to $*r*_{*i*}$, Alyona wants to know the maximum width among all hills. The width of a hill is the number of towers in it.

翻译中…

Input

翻译中…

The first line contain single integer $*n*$ ($1 ≤ *n* ≤ 3·10^{5}$) — the number of towers.

翻译中…

The second line contain $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$) — the number of cubes in each tower.

翻译中…

The third line contain single integer $*m*$ ($1 ≤ *m* ≤ 3·10^{5}$) — the number of additions.

翻译中…

The next $*m*$ lines contain $3$ integers each. The $*i*$-th of these lines contains integers $*l*_{*i*}$, $*r*_{*i*}$ and $*d*_{*i*}$ ($1 ≤ *l* ≤ *r* ≤ *n*$, $1 ≤ *d*_{*i*} ≤ 10^{9}$), that mean that Alyona puts $*d*_{*i*}$ cubes on the tio of each of the towers from $*l*_{*i*}$ to $*r*_{*i*}$.

翻译中…

Output

翻译中…

Print $*m*$ lines. In $*i*$-th line print the maximum width of the hills after the $*i*$-th addition.

翻译中…

Note

翻译中…

The first sample is as follows:

翻译中…

After addition of $2$ 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]$. The hill with maximum width is $[7, 5]$, thus the maximum width is $2$.

翻译中…

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

翻译中…

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

翻译中…

样例

Input #1
5
5 5 5 5 5
3
1 3 2
2 2 1
4 4 1
Output #1
2
4
5
InputCopy OutputCopy
题目信息
题号
739C
时间限制
2 s
内存限制
256 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。