Editorial for Bubble Cup V9 D Potions homework


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.

Everything is pretty simple here. What should be done here is to give the laziest student the easiest task, because it is always optimal to do so. If we do that continuously, it becomes obvious that the solution is to sort the given array and use the following formula:

\displaystyle \sum_{i=1}^N A[i] \times A[N-i-1]


Comments

There are no comments at the moment.