HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50914 - Buy 3, Pay 2

Guest
• Review clarifications (1)

Volume problems

• 50930 - Tom and Jerry
• 50925 - Optimizing Elevator Usage
• 50988 - Laplacian Filter
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II
• 50791 - Mine field
• 50912 - Trip to Librazhd
• Trip to Librazhd
• 50914 - Buy 3, Pay 2
• 50555 - Frequency of Letters
• 50558 - Biggest Barn
• 50563 - Long Modulus
• 50565 - Binary numbers
• 50567 - Input Data Normalization
• 50569 - 12th Grade Elective Subjects
• 50585 - Inner Product
• 50587 - Modular Conversion

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question from Croatian Olympiads, prepared by Ibrahim Mesecan.

Buy 3, Pay 2

Question: The company that you work started a new promotional season. People buy any three items, and they don't pay for the cheapest item (of the three). Write a program that reads product information for n items and calculates the minimum amount (for the customer) to pay. Pay attention that the items may be grouped differently and different results may come. For example if you are given the prices: 5 5 3 4 2 1 and if you process with the groups: (5 5 3) (4 2 1), the customer has to pay $16. However, if you group (5 4 5) (3 2 1), the customer has to pay $15. Find the minimum total amount to pay.

Input specification
You will be first given a number n, the number of numbers where 0 ≤ n ≤ 10,000. Then, in the following n lines, you will be given n numbers where the numbers are floating point numbers between 0 and 10,000. Please note that n does not have to be a multiple of three.

Output specification:
Show the result with digits precision: minimum total amount to pay.

Sample Input I
6
5
5
3
4
2
1
Sample Input II
4
3
7.2
4
5
Sample Output I
15.00
Sample Output II
15.20

Explanation (for Sample input 2): If you group, 7 5 and 4, $4 will be free. Because there is no other triple, he has to pay for: 7+5+3 = $15



Для отправки решений необходимо выполнить вход.

www.contester.ru