This page is still under construction.

Parts of this page are still being built. What you see may change.

Knapsack Collection

Time limit4sMemory limit512 MB

Summary
Over every starting slot, find the min, max, and average time to collect all bags from a rotating carousel when each pickup takes t units.
Level

Medium6 of 10

Topics
Sorting, Prefix sum, Math
Solved
No attempts yet

Problem

Gerald welcomes the teams arriving for a programming contest at the airport. One of his duties is to stand at the luggage carousel and collect every knapsack the teams bring. Gerald is a lazy person, so he stays at one position of the carousel and waits for bags to pass by so he can pick them up.

The carousel consists of ss luggage slots, numbered in ascending order from 00 to s−1s-1. The carousel is cyclic, so slots s−1s-1 and 00 lie side by side as well. It turns so that if Gerald stands in front of slot ii at some point in time, he stands in front of slot (i+1) mod s(i+1) \bmod s one time unit later.

In the beginning Gerald prepares a huge baggage cart at some slot and stands there to wait for luggage. When a knapsack arrives in front of him, he needs tt time units to take it and put it on the cart. After these tt time units he is ready to pick up another knapsack. As long as knapsacks remain on the carousel, Gerald takes the next one to arrive at his position once he is ready.

Gerald wonders how his choice of position changes the time the task takes. There are ss slots that can appear in front of him after the preparation. Compute the minimum, the maximum, and the average time needed to pick up all knapsacks, taken over those ss slots. Time starts when he has prepared the cart at some slot and ends when he has put the last knapsack on the cart.

Input

The first line contains three integers nn, ss and tt (1≤n≤20001 \le n \le 2000, 1≤s≤1071 \le s \le 10^7, 1≤t≤1071 \le t \le 10^7), where nn is the number of knapsacks to pick up, ss is the number of slots of the carousel, and tt is the number of time units Gerald needs to take one knapsack from the carousel and put it on the cart.

The second line contains nn integers k1,…,knk_1, \ldots, k_n (0≤ki≤s−10 \le k_i \le s-1), the slots of the knapsacks.

Several knapsacks may be stacked on top of each other in the same slot, but Gerald still picks up only one knapsack at a time.

Output

Print three lines: the minimum time, the maximum time, and the average time over all ss starting slots.

Print the average as a reduced fraction p/q, where q≥1q \ge 1 and the greatest common divisor of pp and qq is 11. When the average is an integer, print it with denominator 11, for example 16/1.

Examples3

  1. Example 1

    Input
    7 10 10000000
    0 0 0 0 0 0 1
    
    Expected output
    70000001
    70000009
    350000027/5
    
  2. Example 2

    Input
    10 10 3
    0 0 2 2 4 4 6 6 8 8
    
    Expected output
    39
    40
    79/2
    
  3. Example 3

    Input
    9 10000000 1
    0 7 2 3 4 5 6 1 8
    
    Expected output
    9
    10000000
    12500021249991/2500000