Time limit: 1 second Memory limit: 256 MB T-net which is a new telecommunications…
- User
Time limit: 1 second Memory limit: 256 MB T-net which is a new telecommunications company, plans to install its base stations in the city. The places where base stations must be installed have already been specified. T-net has two types of antennas to be used in the base stations: (i) antennas with transmission radius a a, and (ii) antennas with transmission radius b b. Two antennas can communicate with each other if and only if both are inside the coverage area of each other. Antenna with smaller transmission radius of course is cheaper. T-net plans to minimize its cost while keeping the entire network connected. Precisely, T-net plans to minimize its cost which is the sum of the transmission radii of all antennas. Interestingly, all base-station places are on a line. Help T-net construct a connected network with the minimum cost.
input The first line of the input contains three positive integers n , a n, a and b b ( 1 ≤ n ≤ 1 0 5 1≤n≤10 5 and 1 ≤ a , b ≤ 1 0 5 1≤a,b≤10 5 ) where n n is the number of base stations, and a a and b b are radii as defined in the problem statement. The second line contains n n distinct coordinates of base stations on the line with respect to an origin on the line. All coordinates are positive integers not more than 1 0 5 10 5 .
output If it is possible to construct a connected network, print the minimum cost in the output. Otherwise, print -1.
Example Sample entry 1 3 1 3 1 4 3 Plain text Sample output 1 7 c++
- Assistant
The problem requires us to assign transmission radii to base stations lined up in a linear manner. Each base station can use either a smaller radius ( a ) or a larger radius ( b ). Our goal is to select the radii for all stations such that the entire network remains connected and the total cost (sum of all the radii used) is minimized.