#P14218. [ICPC 2024 Kunming I] 金牌
[ICPC 2024 Kunming I] 金牌
Problem Description
What a busy week! This weekend, programming contests will be held at the same time.
Each contest will award one gold medal for every teams that participate in it. That is, if teams participate in a contest, it will award gold medals, where is the largest integer not exceeding . Currently, the -th contest has teams participating.
Baobao is the coach of a university which has teams, and he has not decided which contest each team should participate in. Please help him assign one contest to each team so that the total number of gold medals awarded by all contests is maximized.
Input Format
There are multiple test cases. The first line contains an integer () denoting the number of test cases. For each test case:
The first line contains two integers and (, ), denoting the number of contests and the medal ratio.
The second line contains integers (), where denotes how many teams currently participate in the -th contest.
The third line contains one integer (), denoting the number of teams you need to assign to contests.
Output Format
For each test case, output one line with one integer denoting the maximum total number of gold medals that all contests can award.
2
3 10
239 141 526
6
2 1
300 100
1000
91
1400
Hint
For the first sample, send teams to the -st contest and teams to the -rd contest. The total number of gold medals is $\lfloor \frac{239 + 2}{10} \rfloor + \lfloor \frac{141 + 0}{10} \rfloor + \lfloor \frac{526 + 4}{10} \rfloor = 24 + 14 + 53 = 91$.
Translated by QwenWork