Grocery Greed
Time limit2sMemory limit1024 MB
Given item prices, split the items into groups paid either by card (exact) or cash (rounded to the nearest 0.05 euro), and find the minimum total.
Problem
Recently, you have acquired the newest book in the self-help category: "Becoming A Professional Consumer", which contains a wide variety of tips on how to buy as much as possible while paying as little as possible. While reading it, you discovered that you have been paying too much for your groceries all your life.
This works as follows. At a supermarket, you can pay with card or with cash. If you pay with cash, the amount you owe is rounded to the nearest multiple of €0.05. If you pay with card, it is not rounded. So, depending on your groceries, paying with the right method can be cheaper. You can lower your spending further by splitting your groceries into multiple groups and paying for each group separately.
You have already decided which items you will buy and know their prices. What is the cheapest way to buy all of these groceries?
Input
The first line contains an integer (), the number of items you want to buy.
The second line contains floating point numbers (), the prices of the items in euros. Each price is written in decimal form with exactly two decimal places. Decimal form means the number is not written in scientific notation.
Output
Output the minimal total amount you need to buy all the groceries, in euros. Your answer must have exactly two decimal places.