Editorial for COCI '15 Contest 5 #4 Poplava
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.
Let's first notice that the maximal amount of water contained in a histogram with
The main idea of the solution is to remove several columns from the middle and put them in descending order on the side. Then the total amount of water would depend only on the columns left in the middle. A column of height
Let's assume that we left columns of height
Comments