#P2497. [SDOI2012] 基站建设
[SDOI2012] 基站建设
Description
The uploader (UP 主) finally bought a computer, but now there are various issues to deal with. The first problem to solve is the network. He wants to start from the mobile company and relay the network to his home through some base stations.
To simplify the problem, we assume the mobile company, all base stations, and the UP's home lie on the same straight line, each located at some point on this line. These points may coincide. Each base station’s transmit and receive ranges are circles tangent to the ground. The transmit radius is fixed, while the receive radius is adjustable. See the figure:

If base station wants to receive a signal from another base station (if and only if ), it must satisfy that ’s receive range is tangent to ’s transmit range, and an extra cost of must be paid. Activating each point costs .
For the UP’s home to receive a signal from some base station, it suffices that this station’s transmit range is tangent to or intersects the vertical line passing through the UP’s home, as shown below:

Of course, the smaller the total cost, the better, so the UP wants your help.
Input Format
The first line contains two integers : the number of base stations (including the mobile company), and the coordinate of the UP’s home. It is guaranteed that is greater than or equal to the coordinates of all base stations.
The next lines each contain three integers , , , representing the coordinate, transmit radius, and activation cost of each base station.
The are given in increasing order of coordinates, and the mobile company is at the smallest coordinate.
The sequence is a permutation of .
Output Format
Output a real number with exactly three digits after the decimal point.
10 33
5 4 660
10 2 2040
11 6 3207
14 5 2006
18 3 6130
19 9 3363
22 1 1265
25 8 2836
27 10 7961
29 7 9075
3501.000
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号