This page is still under construction.

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

Wi-Fi Setup

Interview

Time limit1sMemory limit128 MB

Summary
Cover all cow positions on a line with base stations, where a station covering an interval of length 2r costs A + B*r; minimize total cost.
Level

Medium6 of 10

Topics
Dynamic programming, Sorting, Greedy, Math
Solved
No attempts yet

Problem

Farmer John's NN cows (1≤N≤20001 \le N \le 2000) are standing at various positions along the straight path from the barn to the pasture, which we can think of as a one-dimensional number line. Because his cows like to stay in contact with each other, FJ wants to install Wi-Fi base stations at various positions so that all of the cows have wireless coverage.

The cost of a base station depends on the distance it can transmit (its power): a base station of power rr costs A+B⋅rA + B \cdot r, where AA is a fixed cost for installing the station and BB is a cost per unit of transmission distance. If FJ installs such a device at position xx, it can transmit to any cow located in the range x−rx - r through x+rx + r. A base station with power r=0r = 0 is allowed, but it only covers a cow located at exactly the same position as the transmitter.

Given the values of AA and BB as well as the locations of FJ's cows, determine the least expensive way FJ can provide wireless coverage for all of his cows.

Input

  • Line 1: Three space-separated integers NN, AA, and BB (0≤A,B≤10000 \le A, B \le 1000).
  • Lines 2 through N+1N+1: Each line contains an integer in the range 0…1,000,0000 \ldots 1{,}000{,}000 giving the location of one of FJ's cows.

Output

  • Print the minimum cost of providing wireless coverage to all cows.
  • The answer is always a multiple of 0.50.5. If it is an integer, print it with no decimal part; otherwise print it followed by .5 (for example, 57.5).

Hint

Suppose there are 3 cows at positions 77, 00, and 100100, and a base station of power rr costs 20+5r20 + 5r. The optimal solution is to build a base station at position 3.53.5 with power 3.53.5, covering the cows at positions 00 and 77, and another station at position 100100 with power 00. The total cost is (20+5⋅3.5)+(20+5⋅0)=37.5+20=57.5(20 + 5 \cdot 3.5) + (20 + 5 \cdot 0) = 37.5 + 20 = 57.5.

Examples4

  1. Example 1

    Input
    3 20 5
    7
    0
    100
    
    Expected output
    57.5
    
  2. Example 2

    Input
    1 10 5
    42
    
    Expected output
    10
    
  3. Example 3

    Input
    2 20 5
    0
    100
    
    Expected output
    40
    
  4. Example 4

    Input
    2 1 1
    0
    1
    
    Expected output
    1.5