Editorial for COCI '16 Contest 5 #2 Pareto
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.
We will sort the amounts descendingly by size, from the largest to the smallest one. For each "prefix" that consists of richest clients, we will calculate the corresponding numbers and , the share of that prefix in the number of accounts () and the total share of the money for that prefix:
We now check if the difference is the largest so far: if it is, we update the temporary variables , , the ones we output in the end.
Given the size of the array, we need to efficiently sort it, in the complexity , and then efficiently calculate the sum of prefixes. The easiest way to do so is to calculate the sum of -prefix by adding the element to the previously calculated -prefix.
Comments