FORESTGA - Editorial

My solution is giving TLE even though the complexity is O(n log n)

I am getting wrong answer for only few test cases can someone please help

Can you please explain a little bit, how solution using min heap is working ?

The maximum answer is 10^18-1, so 10^18 (or even 10^18-1) is good as an upper bound.

I got TLE many times using binary Search too… it got removed when I declared arrays globally instead of declaring locally and passing them again and again…

Thank you for the solution! This taught me a lot.

Thanks your tips works to handle overflows…