#P3062. [USACO12DEC] Wifi Setup S

[USACO12DEC] Wifi Setup S

Description

Farmer John’s NN cows (1N20001 \le N \le 2000) stand at various positions along a straight path, which we can regard as a one-dimensional number line. Since his cows want to stay in email contact with each other, FJ plans to install Wifi base stations at positions of his choosing so that all cows have wireless coverage.

The cost of a Wifi base station depends on its transmission distance: a base station with power rr costs A+B×rA + B \times r, where AA is the fixed installation cost and BB is the cost per unit distance. If a base station is installed at position xx, it provides coverage to any cow located in the interval [xr,x+r][x - r, x + r]. A base station with r=0r = 0 is allowed, but it only covers a cow located exactly at xx.

Given AA, BB, and the locations of FJ’s cows, determine the minimum total cost to provide wireless coverage for all cows. Base stations may be placed at any real position on the line.

Input Format

  • Line 1: Three space-separated integers NN, AA, BB, where 1N20001 \le N \le 2000 and 0A,B10000 \le A, B \le 1000.
  • Lines 22 to N+1N + 1: Each line contains an integer in [0,1,000,000][0, 1{,}000{,}000] describing the location of one cow.

Output Format

  • Line 1: The minimum total cost to provide wireless coverage to all cows.
3 20 5 
7 
0 
100 

57.5 

Hint

There are 33 cows at positions 77, 00, and 100100. Installing a base station of power rr costs 20+5×r20 + 5 \times r.

An optimal solution is to build one base station at position 3.53.5 (power r=3.5r = 3.5) and another at position 100100 (power r=0r = 0). The first base station covers cows 11 and 22, and the second covers cow 33.

Translated by ChatGPT 5