#P9313. [EGOI 2021] Shopping Fever / 购物热
[EGOI 2021] Shopping Fever / 购物热
Background
Day 2 Problem A.
Translated from EGOI2021 shoppingfever.
Problem Description
Heidi is in a large store. She wants to buy items.
Today is her lucky day. The store is having a promotion: for each bill, the customer gets one of the following two discounts:
- If at least items are bought, the cheapest one is free.
- If fewer than items are bought, this bill gets a discount.
Heidi wants to buy all items without buying any item more than once. She may split the purchase into any number of bills. For each bill, the corresponding discount policy will be applied.
What is the minimum amount of money she needs to pay to buy all items?
Input Format
The first line contains two integers — the number of items and the discount percentage when buying fewer than items.
The second line contains integers — the prices of the items.
It is also guaranteed that each item price is divisible by . Therefore, the discounted price for each bill is always an integer.
Output Format
One line with one integer — the minimum amount of money needed.
7 10
300 200 200 300 100 300 200
1090
3 20
1000 500 100
1280
4 0
200 100 300 200
600
Hint
Explanation for Sample
Heidi first buys three items priced at , paying (one item is free). Then she buys three items priced at , paying (again, one item is free). Finally, she buys the remaining item priced at and gets a discount.
Explanation for Sample
If Heidi buys three items in a single bill, she gets a discount of . However, if she buys the three items in three separate bills, the discount becomes .
Constraints
For all testdata, , , , and .
- Subtask 1 ( points): , .
- Subtask 2 ( points): .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): no additional constraints.
Translated by ChatGPT 5