#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 nn items.

Today is her lucky day. The store is having a promotion: for each bill, the customer gets one of the following two discounts:

  1. If at least 33 items are bought, the cheapest one is free.
  2. If fewer than 33 items are bought, this bill gets a q%q\% discount.

Heidi wants to buy all nn 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 nn items?

Input Format

The first line contains two integers n,qn, q — the number of items and the discount percentage when buying fewer than 33 items.

The second line contains nn integers pip_i — the prices of the items.

It is also guaranteed that each item price is divisible by 100100. 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 11

Heidi first buys three items priced at 200200, paying 400400 (one item is free). Then she buys three items priced at 300300, paying 600600 (again, one item is free). Finally, she buys the remaining item priced at 100100 and gets a 10%10\% discount.


Explanation for Sample 22

If Heidi buys three items in a single bill, she gets a discount of 100100. However, if she buys the three items in three separate bills, the discount becomes (1000+500+100)20100=320(1000+500+100)\cdot\frac{20}{100}=320.


Constraints

For all testdata, 1n1051\le n\le 10^5, 0q1000\le q\le 100, 100pi105100\le p_i\le 10^5, and 100pi100\mid p_i.

  • Subtask 1 (88 points): n=3n=3, 100pi103100\le p_i\le 10^3.
  • Subtask 2 (1818 points): q=0q=0.
  • Subtask 3 (1616 points): q=40q=40.
  • Subtask 4 (2222 points): 100pi103100\le p_i\le 10^3.
  • Subtask 5 (3636 points): no additional constraints.

Translated by ChatGPT 5