Problem G
Knapsack Collection

The baggage carousel consists of
In the beginning Gerald prepares a huge baggage cart at some
position and stands there to wait for luggage. When a knapsack
arrives in front of Gerald, he needs
Now Gerald wonders about the effect of his choice of
position on the time it will take him to finish this task. It
is up to you to help Gerald calculate the minimum, maximum, and
average time to pick up all knapsacks, taken over all
Input
The input consists of:
-
one line with three integers
( ), ( ) and ( ), where is the number of knapsacks to pick up, is the number of slots of the carousel, and is the number of time units Gerald needs to pick up a knapsack from the carousel and put it on the cart; -
one line with
integers ( for ), the slots of the knapsacks.
There may be several knapsacks stacked on top of each other in the same slot, but Gerald can still only pick up one knapsack at a time.
Output
Output three lines of output containing the minimum,
maximum, and average time to pick up all the luggage, over all
Sample Input 1 | Sample Output 1 |
---|---|
7 10 10000000 0 0 0 0 0 0 1 |
70000001 70000009 350000027/5 |
Sample Input 2 | Sample Output 2 |
---|---|
10 10 3 0 0 2 2 4 4 6 6 8 8 |
39 40 79/2 |
Sample Input 3 | Sample Output 3 |
---|---|
9 10000000 1 0 7 2 3 4 5 6 1 8 |
9 10000000 12500021249991/2500000 |