Food Portion Size

Time limit1sMemory limit128 MB

Summary
Choose a real portion size S to minimize a*(wasted food) + b*(number of servings, each student at most 3), and print the optimum as a reduced fraction.
Level

Medium7 of 10

Topics
Math, Brute force, Implementation, Greedy
Solved
No attempts yet

Problem

A university canteen never wants a student to leave hungry, so as long as a student is still hungry they may take another portion of food for free. To avoid wasting time, the canteen always serves one fixed portion size SS instead of first asking each student how much they want. Because of this, a student might not finish their final portion, and whatever is left over must be thrown away.

To keep costs down, the manager wants to choose a portion size SS so that little food is wasted while students also do not have to come back for more food too often. The two goals conflict:

  • A very small SS wastes almost no food, but students must refill many times.
  • A very large SS lets each student take just one portion, but a large amount of food may be wasted.

The manager has recorded how many units of food each student eats. Let xx be the total food wasted and let yy be the total number of times students go to fetch food. The goal is to minimize a⋅x+b⋅ya \cdot x + b \cdot y, where the weights aa and bb express the relative importance of the two goals. Both xx and yy depend on the portion size SS (which may be any positive real value) and on how much each student eats. One extra rule applies: no student may fetch food more than 33 times.

Input

The input contains several test cases. Each test case begins with a line containing an integer nn (1≤n≤10001 \le n \le 1000), the number of students. The next line contains two integers aa and bb (1≤a,b≤101 \le a, b \le 10). The third line contains nn integers y1,…,yny_1, \ldots, y_n (1≤yi≤1001 \le y_i \le 100), where yiy_i is the number of food units that student ii eats. The input ends with a line containing n=0n = 0, which should not be processed.

Output

For each test case, print one line with the minimum possible value of a⋅x+b⋅ya \cdot x + b \cdot y over all valid portion sizes. Print the value as a reduced fraction in the form p / q. If the value is an integer, print only the numerator and omit the denominator 11.

Examples1

  1. Example 1

    Input
    5
    1 1
    3 7 1 9 12
    3
    10 1
    11 13 17
    2
    2 3
    6 3
    0
    
    Expected output
    35 / 2
    154 / 3
    9