Hello, since gym doesn't allow to see others solutions could someone help with this problem:
i have tried this solution but got WA
Hello, since gym doesn't allow to see others solutions could someone help with this problem:
i have tried this solution but got WA
| № | Пользователь | Рейтинг |
|---|---|---|
| 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 | nik_exists | 146 |
| 4 | Um_nik | 145 |
| 5 | Errichto | 139 |
| 6 | adamant | 136 |
| 7 | maroonrk | 134 |
| 8 | DNR | 132 |
| 9 | AmShZ | 131 |
| 10 | Dominater069 | 129 |
| Название |
|---|



You actually don't need DP to solve this problem.
Think of it like this, Bus Stops means that you have segments in the form $$$(li, ri)$$$. In these segments you don't need to walk.
This means that if consecutive segments (let's say $$$(li, ri)$$$ & $$$(lj, rj)$$$ assuming $$$ri \lt =lj$$$ and $$$rj \gt =ri$$$) are intersecting you don't need to walk in the segment $$$(li, rj)$$$ at all.
So now this problem becomes for the distance (1, n) how many places have no segments. That is the answer. For merging segments you can sort and merge, I think it's pretty well known.
thx, appreciate that!