Hello, since gym doesn't allow to see others solutions could someone help with this problem:
i have tried this solution but got WA
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 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
Name |
---|
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!