Editorial for Yet Another Contest 7 P1 - Page Turning
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.
Author:
Subtask 1
Every piece where
Time complexity:
Subtask 2
Since pieces with odd lengths always have the same inconveniences, we should focus on the pieces where
It follows that we should maximise the number of pieces with even length that start on an even page. There are two possible cases:
- If there is at least one piece with an odd length, we should output one piece with a odd length, then all of the pieces with even lengths, then all the remaining pieces with odd lengths. This allows every piece with an even length to start on an even page.
- If every piece has an even length, then every piece will start on an odd page. Thus, the ordering of the pieces doesn't matter.
Time complexity:
Comments