Akcija

Question

Solution

Idea

Seems that it is a sorting problem.

  1. Sort the price in decreasing order. (The problem seems that we need a fast sorting algorithm, the normal O(N2)O(N^2) method will cause TLE)

  2. Iterate through each price element, add the first two in the group only.

The second step can be done as follows elegantly:

Code

Last updated