Editorial for COCI '11 Contest 4 #2 Zima
Submitting an official solution before solving the problem yourself is a bannable offence.
First, we traverse the given day temperatures and locate the winter periods. Every winter period starts with a negative number, and lasts until a positive number is encountered.
If there is a winter period starting with day and lasting days, we mark all days from to (inclusive) in some boolean array. This array tells us during which days are we allowed to announce the winter. We also keep track of the length of longest winter period so far.
Finally, we must choose one of the longest winter periods and allow it's announcing days in advance. We do this by checking for each of the longest periods by how much will our solution increase if we choose that period, and then choosing the one that was optimal. This checking is easy to do by using the same array of booleans as before.
Comments