문제
Problem 2: Wifi Setup [Brian Dean, 2012]
Farmer John's N cows
After shopping around, FJ learns that the cost of a Wifi base station depends on distance it can transmit: a base station of power r costs A + B*r, where A is a fixed cost for installing the base station and B is a cost per unit of transmission distance. If FJ installs such a device at position x, then it can transmit data to any cow located in the range
Given the values of A and B, as well as the locations of FJ's cows, please determine the least expensive way FJ can provide wireless coverage for all his cows.
PROBLEM NAME: wifi
입력
* Line 1: Three space-separated integers:
* Lines 2..1+N: Each line contains an integer in the range
출력
* Line 1: The minimum cost of providing wireless coverage to all cows.
예제1
3 20 5
7
0
100
57.5
INPUT DETAILS: There are 3 cows at positions 7, 0, and 100. Installation of a base station of power r costs 20 + 5*r.
OUTPUT DETAILS:
The optimal solution is to build a base station at position 3.5 (with power 3.5) and another at position 100 (with power 0). The first base station covers cows 1 and 2, and the second covers cow 3.