Editorial for DMOPC '18 Contest 6 P4 - Tank


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.

Authors: r3mark

Sort the physical and magical attacks by their value and compute a prefix sum for each one. For each unit, we can binary search the attacks to determine how many attacks are completely negated due to their defense/resistance, as well as the total of the attacks which are not negated using the prefix sum. Then we can compute the total damage for each unit by subtracting their defense/resistance multiplied by the number of non-negated attacks from the total of the attacks not completely negated.

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


Comments

There are no comments at the moment.