Akcija
Last updated
Last updated
Seems that it is a sorting problem.
Sort the price in decreasing order. (The problem seems that we need a fast sorting algorithm, the normal method will cause TLE)
Iterate through each price element, add the first two in the group only.
The second step can be done as follows elegantly: