Editorial for COCI '15 Contest 6 #2 Putovanje


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 only important thing to do is to simulate Mislav's movement and food consumption if he starts his journey from every possible position and decides to start eating from that point. When he starts eating, he will eat a fruit if it can fit inside his stomach, otherwise he will not eat it and continue trying to eat other fruits. Therefore, we need to calculate how much fruit he will eat if he starts eating from the fruit on that position, from every position. The maximal obtained number is the solution. The total complexity of this solution is \mathcal O(n^2).


Comments

There are no comments at the moment.