PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000128. Khuyến mãi mua ba trả hai (Akcija)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Khuyến mãi mua ba trả hai (Akcija)
Akcija
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A bookstore offers one free cheapest book in every group of three purchased books; the two more expensive ones must be paid for. Remaining books may be purchased separately. Given all book prices, find the minimum amount paid.
Input
The first line contains . Each of the next lines contains one price .
Output
Print the minimum total price paid.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
6
10
9
8
7
6
5
Output
32
Explanation
Group prices and . Prices and are free; from total , pay .