|
||||||||||
Food portion sizeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 217 Accepted Submission(s): 58 Problem Description 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:
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 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 y1, ..., yn (1 ¡Ü yi ¡Ü 100), where yi is the amount of food student i eats. Input is terminated by n=0. Output 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
Sample Output
Hint 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. Source | ||||||||||
|