Editorial for IOI '04 P2 - Hermes
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.
Let be the points where is the starting point. We will compute and where is the cost to align with the first points and end up at and is the cost to align with the first points and end up at . We have:
The final answer is .
Time complexity:
Comments