Editorial for TLE '16 Contest 6 (Mock CCC) J1 - Paper Printing


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.

Throughout the operation of the printer, we must keep track of how many pieces of paper are present at a specific time. This can either be monitored every second or, more efficiently, at every action.

To find out the current number of paper in the feed at any given action, we must first determine how much time elapsed since the previous action. Subtracting that from our previous paper count evaluates to the leftover number of paper currently in the feed. However, if that number is negative, it represents the amount of time prior to the current action since the printer started to overheat. Keep in mind that this will never occur before the previous action, since Leon cannot remove more paper from the feed than there currently is.

Time Complexity: \mathcal{O}(A)


Comments

There are no comments at the moment.