Editorial for DMOPC '22 Contest 4 P1 - Alone Time


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.

Author: Riolku

Subtask 1

No moving is possible, so simply calculate the answer.

Subtask 2

Try moving both classes. It is optimal to move each class either as left as possible, or as right as possible.

Subtask 3

Consider each class gap independently. We can try moving each class that bounds this gap up to K away (note that it may cross over a different class), and calculate the resulting gap size. Try this for all gaps.


Comments

There are no comments at the moment.