No.865 24-Hour Precipitation
タグ : / 解いたユーザー数 163
作問者 :
e869120
/ テスター :
butsurizuki
Problem Statement
E869120 knows the precipitation data for $N$ hours in yuki City.
Initially, the precipitation in hour $i$ ($1 \leq i \leq N$) (the period between $i-1$ hours and $i$ hours after the start of the data) was $A_i$ millimeters.
He tried to calculate the maximum precipitation over $24$ consecutive hours within the $N$ hours of data.
However, as the analysis of the data progresses, the data is changed $Q$ times.
- In the $j$-th change ($1 \leq j \leq Q$), the precipitation in hour $T_j$ is changed to $V_j$ millimeters.
- However, no change to the data ever decreases the precipitation in that hour.
After each change, output the maximum $24$-hour precipitation.
Output
All input data satisfy the following constraints.
- $N$ is an integer between $24$ and $200 \ 000$, inclusive
- $Q$ is an integer between $1$ and $200 \ 000$, inclusive
- $T_j$ is an integer between $1$ and $N$, inclusive
- $A_i$ is an integer between $0$ and $153$, inclusive
- $V_j$ is an integer between $0$ and $153$, inclusive
- No change decreases the precipitation
Input
$N$ $A_1$ $A_2$ $A_3$ ... $A_N$ $Q$ $T_1$ $V_1$ $T_2$ $V_2$ $T_3$ $V_3$ ... $T_Q$ $V_Q$
Output
Output $Q$ lines.
On line $i$, output the maximum precipitation over $24$ consecutive hours immediately after the $i$-th change.
Sample
Sample 1
Input
25 0 0 0 0 2 3 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 2 5 13 2 1 0 1 80
Output
27 94
Immediately after the $2$-nd change, the precipitation is $[80, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 5, 13]$. At that point,
- the $24$-hour precipitation from $0$ hours to $24$ hours after the start is $94$ millimeters
- the $24$-hour precipitation from $1$ hours to $25$ hours after the start is $27$ millimeters
Therefore, the maximum $24$-hour precipitation is $94$.
Sample 2
Input
24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 24 1 153 2 153 3 153 4 153 5 153 6 153 7 153 8 153 9 153 10 153 11 153 12 153 13 153 14 153 15 153 16 153 17 153 18 153 19 153 20 153 21 153 22 153 23 153 24 153
Output
452 603 753 902 1050 1197 1343 1488 1632 1775 1917 2058 2198 2337 2475 2612 2748 2883 3017 3150 3282 3413 3543 3672
Note that a change may increase the precipitation or leave it unchanged, but never decreases it.
Sample 3
Input
30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 5 0 8 0 11 0 3 0 24 0 25 0 16 0 17 0 4 0 19 0
Output
0 0 0 0 0 0 0 0 0 0
This seems to be business as usual in the country of yuki.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。