I have no idea on how to solve this problem! And there is no Editorial for this even though this problem was asked on CodeChef Challenge.

My logic - every time the elephant uses one bottle, the total sum of heights of all the bamboo is increased by (n-2) where n is the number of tree. So the first thing to check is if the difference between the total sum of required height and the total sum of current height is divisible by (n-2). Now we need to check that every tree reaches its required height in (difference of sum of all bamboo)/(n-2) steps. To check this we have to make sure that the difference of height of individual bamboo is less than or equal to the number of steps. We also have to check that, if the no. to steps are even/odd then the difference between heights of all the bamboo should also be even/odd.

@thespacedude Here, is the editorial for the problem. Please go through it. If you are still unable to start, please do comment. We are more than happy to help.

thanks for the page! Also can you link this to the problem’s page so that users will find it easily? I thought that if there isn’t an Editorial link on the bottom of the problem’s page, the setters have not made one yet! I’m new.