Hello, can any one please tell how to solve this question
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | maspy | 150 |
| 3 | Um_nik | 144 |
| 4 | Errichto | 139 |
| 4 | nik_exists | 139 |
| 6 | adamant | 136 |
| 7 | maroonrk | 134 |
| 8 | DNR | 132 |
| 9 | AmShZ | 131 |
| 10 | Dominater069 | 129 |
Hello, can any one please tell how to solve this question
| Название |
|---|



Basically the problem is, given array $$$A$$$ of length $$$n$$$, queries of the form
find $$$x$$$ : find leftmost index with $$$A_i \gt = x$$$
upd $$$i$$$ $$$y$$$ : increase $$$A_i$$$ by $$$y$$$
So we need to use a segment tree to maintain RMQ of $$$A$$$. Updates are standard. When a query comes, we first check for maximum in the interval $$$[1,n]$$$. If it's $$$ \lt x$$$ then the ans is $$$0$$$. Otherwise check if max in $$$[1,n/2] \gt = x$$$. In that case we move left, otherwise we go right and query.
Complexity : $$$O(n lg n)$$$