DMOPC '16 Contest 1 P3 - Shoe Shopping

View as PDF

Submit solution

Points: 8
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Captain Akeno and the crew stopped at a floating mall to replenish the ships supply of toilet paper. As any normal girl does, the captain stopped at a shoe store, where they had two awesome deals. The deals are as follows:

  • If you group two pairs of shoes, you get the cheaper one at a 50% DISCOUNT.
  • If you group three pairs of shoes, you get the cheapest one for FREE.

Captain Akeno had already placed the pairs of shoes on the conveyor when she was told that she can only group adjacent pairs. The group of girls didn't have much money at hand, so they kindly ask you to tell them the minimum obtainable price.

Input Specification

The first line of input will contain the integer N (1 \le N \le 10\,000), the number of pairs of shoes.
The second line of input will contain N space-separated integers representing the prices of the pairs of shoes.

Output Specification

On the first line, you must print the smallest obtainable price with one decimal.

Sample Input

5
100 27 15 25 400

Sample Output

538.5

Comments


  • 1
    Pleedoh  commented on May 15, 2017, 4:30 p.m. edit 2

    We assume they can get one of each deal right? And they don't affect each other?


  • 2
    Pleedoh  commented on May 13, 2017, 1:28 p.m.

    Should the price round to one decimal, or just express one decimal? Ex: Does 45.78 become 45.7 or 45.8?


    • 2
      wleung_bvg  commented on May 14, 2017, 1:21 a.m.

      It should be rounded. 45.78 becomes 45.8


      • 3
        Pleedoh  commented on May 15, 2017, 1:16 p.m. edited

        Alright, but what if there is no decimal? Ex if the answer is 178, will it mark it as wrong if I output 178.0?


  • 6
    aCookieBreak  commented on Oct. 11, 2016, 8:32 p.m. edit 2

    EDIT: IT HELPS TO READ THE QUESTION


  • 2
    kevinwen  commented on Oct. 11, 2016, 6:38 p.m.

    Can you only do any grouping operation once?


  • 2
    xavier158  commented on Oct. 11, 2016, 3:51 p.m.

    which is the bigger price that a shoe can have?


    • 3
      WallE256  commented on Oct. 11, 2016, 3:59 p.m. edited

      The maximum price of a pair of shoes is 10000.