#P6530. [COCI 2015/2016 #1] AKCIJA
[COCI 2015/2016 #1] AKCIJA
Description
The bookstore is running a promotion.
Now, you can buy books at once, and among the three books, you only need to pay for the two more expensive ones.
Note that this discount does not apply when buying or books at once.
Now, you want to spend as little money as possible to buy books.
Please output the minimum total cost to buy all books.
Input Format
The first line contains an integer .
The next lines each contain an integer . The -th line gives the price of the -th book.
Output Format
Output a single integer, representing the minimum total cost to buy books.
4
3
2
3
2
8
6
6
4
5
5
5
5
21
Hint
Sample Explanation
Sample 1 Explanation
Buy the three books priced together, and then buy the remaining book separately.
Sample 2 Explanation
Buy the three books priced together, and then buy the three books priced together.
Constraints
- For of the testdata, is guaranteed.
- For of the testdata, and are guaranteed.
Notes
This problem is worth points in total.
Translated from Croatian Open Competition in Informatics 2015/2016 Contest #1 T2 AKCIJA.
Translated by ChatGPT 5
京公网安备 11011102002149号