Sometimes long stories are very boring. So we decided to make statement as short as possible!
You have two integer arrays of size n: X and P. Your task is to perform q queries. There are three types of queries:
- 1 \(pos\) x: set \(X_{pos} = x\)
- 2 \(pos\) p: set \(P_{pos} = p\)
- 3 a b: find \(max\{X_i + min(P_i, i - a) | i \in [a, b]\}\)
Input format
The first line of input contains two space separated integers n and q (\(1 \leq n, q \leq 3 \cdot 10^5\)) - size of arrays and number of queries.
The second line of input contains n space separated integers \(X_i\) (\(-10^9 \leq X_i \leq 10^9\)).
The third line of input contains n space separated integers \(P_i\) (\(-10^9 \leq P_i \leq 10^9\)).
Then q lines follow. The i-th of them contains parameters of the i-th query.
The i-th line can be:
- 1 \(pos\) x (\(1 \leq pos \leq n\), \(-10^9 \leq x \leq 10^9\)) - parameters for first type query or
- 2 \(pos\) p (\(1 \leq pos \leq n\), \(-10^9 \leq p \leq 10^9\)) - parameters for second type query or
- 3 a b (\(1 \leq a \leq b \leq n\)) - parameters for third type query
Output format
For each third type query print the answer for it.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial