시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 21 | 8 | 8 | 47.059% |
Kanade has a sequence $A_{1...n}$ and $m$ intervals $[L_i, R_i]$ of indices from $1$ to $n$, bounds included. He does $m$ operations in sequence, one for each interval. For the $i$-th operation, Kanade can choose and perform one of the following two actions:
Now Kanade wants to know the maximum value of $A_{k}$ after these operations. Find the answer for each $k \in [1, n]$.
The first line of input contains two integers $n$ and $m$, the size of the sequence and the number of operations ($1 \leq n, m \leq 2 \cdot 10^5$). The second line contains $n$ integers $A_{1...n}$, the initial sequence ($0 \leq A_i \leq 2 \cdot 10^5$).
Then follow $m$ lines. The $i$-th of them contains two integers $L_i$ and $R_i$ describing the respective interval ($1 \leq L_i \leq R_i \leq n$).
Output $n$ integers, the $i$-th of which is the maximum possible value of $A_{i}$ after $m$ operations.
4 3 0 1 0 1 2 4 1 3 2 3
2 4 3 2