Editorial for DMOPC '15 Contest 1 P2 - Itami and Squad


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: cheesecake

To simulate each squad leader picking the best available soldier, sort the strengths of the soldiers in non-increasing order. We then iterate through the array starting with soldier R-1 (in a 0-index array) and increment by L, adding their respective strengths will result in the maximum strength of Itami's squad.

Time Complexity: \mathcal{O}(N \log N)


Comments

There are no comments at the moment.