#P10529. [XJTUPC 2024] 勘探队

[XJTUPC 2024] 勘探队

Problem Description

An exploration team starts from (0,0)(0,0) and the destination is (0,y)(0,y). They carry equipment numbered from 11 to nn. The weight of equipment ii is mim_i, and it must be placed at any position whose xx-coordinate is xix_i (the yy-coordinate can be any real number). All equipment must be placed in order. Before all equipment with smaller indices have been placed, even if the xx-coordinate requirement is satisfied, the team still cannot place the current one.

When the total weight of the equipment carried by the team is mm, the cost to move one unit of distance is m+Mm + M. Find the minimum total cost for the team to finish placing all equipment and arrive at the destination.

Multiple pieces of equipment can be placed at the same coordinate.

Input Format

The first line contains three positive integers nn (1n1×1041\le n \le 1\times 10^4), MM (0<M300< M \le 30), and yy (0<y2×1050<y\le 2\times 10^5), representing the number of devices, the basic movement cost, and the yy-coordinate of the final destination.

The second line contains nn positive integers mim_i (0<mi300< m_i\le 30), representing the weight of device ii. They are separated by spaces.

The third line contains nn integers xix_i (xi1×104|x_i|\le 1\times 10^4), representing the required xx-coordinate for device ii.

Output Format

Output one line with one positive real number representing the final cost. If your answer is aa and the standard answer is bb, then your answer is considered correct if and only if abmax(1,b)106\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}.

1 25 14
14
12

882.000000

Hint

Walk in a straight line to (12,5)(12,5), the distance is 1313, then walk in a straight line to (0,14)(0,14), the distance is 1515. The total cost is 13×(25+14)+15×25=88213\times (25+14)+15\times 25=882. There is no better solution than this.

Translated by ChatGPT 5