Editorial for COCI '19 Contest 4 #1 Pod starim krovovima


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.

The solution is based on an idea that we should start filling the largest (in terms of volume) glass as much as possible. If we have filled the largest glass, we should move to the next one, and so on until there are no glasses left. In that way, we will certainly end up with as many empty glasses as possible.

The time complexity of this greedy algorithm is \mathcal O(N \log N) due to sorting. Notice that the constraints were much lower in this task so that less efficient sorting algorithms or correct simulations get all points.


Comments

There are no comments at the moment.