QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#3120. Food portion sizes

الإحصائيات

The university canteen does not want any student to leave the canteen hungry. Therefore, as long as a student is hungry, he can get another portion of food for free. The canteen uses a fixed food portion size, because it would take too much time to first ask a student how much food he wanted. It can happen that a student doesn't finish his last portion of food and the remainder has to be thrown away.

To minimize costs, the manager of the canteen wants to determine a food portion size $S$ such that the amount of food that is wasted is small, but also the number of times the students have to fetch another portion of food is not too big. Note that these two goals can be conflicting:

  • By choosing a very small food portion size, one does not waste food, but simultaneously the number of times the students have to fetch food is big.
  • By choosing a large food portion size, one can make sure each student has to fetch only one portion, but at the same time it may happen that a large quantity of food is wasted.

The manager of the canteen has collected data about how many units of food each student eats. The problem to be solved can now be formulated mathematically as follows: Let $x$ be the amount of food that is wasted, and $y$ the number of times the students go to fetch food. Then, the goal is to minimize $a × x + b × y$, where $a$, $b$ are weights that represent the relative importance of the two opposing goals. Note that $x$ and $y$ depend on the food portion size $S$ and the quantities of food each student eats. We impose the additional constraint that no student should have to go more than $3$ times to fetch food.

Input Specification

The input file contains several test cases. Each test case starts with a line containing an integer $n$, ($1 ≤ n ≤ 1000$), the number of students eating in the canteen. The next line contains the values $a$ and $b$ ($1 ≤ a, b ≤ 10$). The third line of each test case consists of $n$ integers $y_1$, $\cdots$, $y_n$ ($1 ≤ y_i ≤ 100$), where $y_i$ is the amount of food student i eats. Input is terminated by $n=0$.

Output Specification

For each test case print one line containing the costs resulting from an optimal choice of the food portion size. Print each value as a reduced fraction. If the result is an integer, do not print the denominator 1. See the sample output for details.

Sample Input

5
1 1
3 7 1 9 12
3
10 1
11 13 17
2
2 3
6 3
0

Sample Output

35 / 2
154 / 3
9

Notes

In the first sample input, the optimal food portion size is 4.5. Note that a food portion size of 3 would yield a smaller cost of 16, the 5th student, however, would have to fetch food 4 times.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.