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 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Hello, since gym doesn't allow to see others solutions could someone help with this problem:
i have tried this solution but got WA
Название |
---|
Auto comment: topic has been updated by Makaty (previous revision, new revision, compare).
instructions unclear: solution page not able to be viewed please send your code in a code block instead
hello, sorry for that :), here is my code:
2 declarations of $$$t$$$? One as an array and another as an input integer? Looks more like Compile Error than WA to me...
yeah i see, but unfortunately it wasn't compile error, when i used
t
in main the compiler took the block scope one instead of the global var so it workedYou 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<=lj$$$ and $$$rj>=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!