DMOPC '16 Contest 1 P3 - Shoe Shopping

View as PDF

Points: 8
Time limit: 0.6s
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 (), the number of pairs of shoes.
The second line of input will contain 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

• 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?

• 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?

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

It should be rounded. 45.78 becomes 45.8

• 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?

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

EDIT: IT HELPS TO READ THE QUESTION

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

Can you only do any grouping operation once?

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

which is the bigger price that a shoe can have?

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

The maximum price of a pair of shoes is 10000.