#P4202. [NOI2008] 奥运物流
[NOI2008] 奥运物流
Description
The 2008 Beijing Olympic Games are about to open, and the whole country is preparing for this grand event. To hold the Games efficiently and successfully, it is essential to plan the logistics system.
The logistics system consists of several logistics base stations, numbered from to . Each logistics base station has exactly one successor station , and may have multiple predecessor stations. All goods at station that need to continue transportation will be sent to its successor station . Obviously, a station cannot be its own successor. Station is called the control station, and goods can be sent from any station to the control station. Note that the control station also has a successor station, so that circulation is possible when needed. In the logistics system, high reliability and low cost are the main design goals. For station , we define its “reliability” as follows: Suppose station has predecessor stations , i.e., these stations take as their successor station, then the reliability of station satisfies:
Here and are fixed positive real numbers, and is less than .
The overall system reliability is positively correlated with the reliability of the control station. Our goal is to modify the logistics system—i.e., change the successors of some stations—so that the reliability of the control station is as large as possible. Due to budget constraints, at most stations’ successors can be modified, and the successor of the control station cannot be modified. Therefore, the problem is: how to modify the successors of no more than stations to maximize the reliability of the control station.
Input Format
The first line contains two integers and a real number, . Here is the number of stations, is the maximum number of successor changes allowed, and is the constant in the reliability definition.
The second line contains integers, , the successor station index of each station.
The third line contains positive real numbers, , the constants in the reliability definition.
Output Format
Output a single real number: the maximum achievable . Round to two decimal places.
4 1 0.5
2 3 1 3
10.0 10.0 10.0 10.0
30.00
Hint
[Sample explanation] In the original logistics system (as shown in the left figure), the reliabilities of the stations are in order.
The optimal plan is to change the successor of station to station .
Then the reliabilities of the stations become in order. The testdata is distributed as follows:
| 测试数据编号 | ||
|---|---|---|
For all testdata, , , . Please use double-precision floating-point numbers; you do not need to worry about the error introduced.
Translated by ChatGPT 5
京公网安备 11011102002149号