Shopping Fever
Heidi is shopping in a large store and plans to purchase items.
Today, she benefits from a special store discount, which offers two options for each purchase:
If she buys at least items together, the cheapest item is free.
If she buys fewer than items, she receives a % discount on the total purchase.
Heidi aims to buy all items on her list, each exactly once. She can make multiple purchases, and the respective discount will apply to each.
What is the minimum total cost Heidi must pay to acquire all items?
Input
The first line contains two integers () and () — the number of items Heidi wants to buy and the percentage discount for purchasing fewer than three items.
The second line lists integers — the prices of the items (, ).
Each is guaranteed to be divisible by 100, ensuring that any discounted price will be an integer.
Output
Output a single line — the minimum total amount Heidi needs to pay to purchase all items.
Examples
Note
In the first example, Heidi can buy three items priced at 200 each for a total of 400, as one item is free. She can then buy another three items priced at 300 each for 600. Finally, she buys the last item, priced at 100, with a discount.
In the second example, if Heidi buys all three items in one transaction, she saves 100. However, if she buys each item separately, her total discount will be .
Scoring
Block 1 (8 points): and ()
Block 2 (18 points):
Block 3 (16 points):
Block 4 (22 points): ()
Block 5 (36 points): no additional constraints.