Hi, I need help in solving this problem
So far, I’ve figured i need to store the positions in a set and binary search for the range at which the current point lies inside, it can only be inside 1 range. I’ve gotten that part right, but i don’t know how to calculate the new maximum for each update.
Here’s my code: https://cses.fi/paste/6dd8197e09444dee15e52e/
Your help will be appreciated : )
Final solution: https://cses.fi/paste/8b589473ba482a5115f5a2/
With your current code, it’s pretty hard to keep track of the maximum after updates because you don’t know if you split the maximum and what the second maximum is then.
Instead, you can consider having another set to keep track of the distances.
1 Like
Thnxs for the tip, it worked
1 Like