I don't know how to do the last subtask, anyone have idea ?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3741 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3443 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 158 |
5 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | djm03178 | 155 |
9 | TheScrasse | 154 |
10 | Dominater069 | 153 |
I don't know how to do the last subtask, anyone have idea ?
Название |
---|
Also interested
I think it's a good idea to put the problem link.
Here :https://oj.uz/problem/view/JOI19_timeleap
WLOG assume that $$$A_j < B_j$$$. Cost of walking is annoying so we can get rid of it by setting $$$[L_i, R_i]$$$ to $$$[L_i-i, R_i-i-1]$$$.
Now at each point we can either increase time or decrease it by paying $$$1$$$. Brute force solution would be trivial: don't change time for as long as possible.
Create a segment tree which will be able to answer the following query: Given a starting time $$$t$$$, find ending time and total cost to walk on a segment $$$[l, r]$$$.
We can get our answer for any $$$t$$$ by setting $$$t=L_l$$$ or $$$t=R_l$$$ depending on the direction our first move in time would be when starting at $$$t$$$.
All we need is a segment tree that for each node stores answer for the $$$2$$$ starting cases.
Can you tell me that 2 cases ?
For a segment tree node covering segment $$$[l, r]$$$ you only consider $$$t=L_l$$$ and $$$t=R_l$$$
Can you explain more, please. I don't understand your idea.
Auto comment: topic has been updated by that_bai_xa_hoi (previous revision, new revision, compare).