Editorial for Baltic OI '11 P1 - Growing Trees
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
This problem can be solved by binary searches and a range-update segment tree, but our solution can be faster.
If for each subtree in the segment tree, we maintain the biggest value in it. As a result, when we want to find the first
element of value
Complexity:
Comments