#P2497. [SDOI2012] 基站建设

    ID: 1511 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp2012线段树各省省选平衡树山东cdq 分治斜率优化

[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 xx on this line. These points may coincide. Each base station’s transmit and receive ranges are circles tangent to the ground. The transmit radius rr is fixed, while the receive radius rr' is adjustable. See the figure:

If base station ii wants to receive a signal from another base station jj (if and only if xj<xix_j < x_i), it must satisfy that ii’s receive range is tangent to jj’s transmit range, and an extra cost of ri\sqrt{r'_i} must be paid. Activating each point ii costs viv_i.

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 n,mn, m: the number of base stations (including the mobile company), and the coordinate of the UP’s home. It is guaranteed that mm is greater than or equal to the coordinates of all base stations.

The next nn lines each contain three integers xix_i, rir_i, viv_i, representing the coordinate, transmit radius, and activation cost of each base station.

The xix_i are given in increasing order of coordinates, and the mobile company is at the smallest coordinate.

The sequence {ri}\{r_i\} is a permutation of 1n1 \dots n.

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 100%100\% of the testdata, n5×105n \le 5 \times 10^5, xi,m1012x_i, m \le 10^{12}, vi10000v_i \le 10000.

Translated by ChatGPT 5