#P4453. [国家集训队] 飞行计划
[国家集训队] 飞行计划
Description
Shenben Airlines has a flight from to and needs to plan the most economical route. To simplify, we assume the ground is a plane at height , with waypoints and bidirectional airways. Each airway connects two waypoints and has two parameters and , meaning that traversing this airway at altitude costs . At each waypoint you may climb or descend; each unit of climb costs , while descending is free. Waypoint is , and waypoint is .
Input Format
The first line contains 3 positive integers , , and , as described above. The next lines each contain 4 integers , indicating there is an airway between and with parameters and .
Output Format
Output a single line with one integer, the minimum cost from to .
3 2 5
0 1 10 10
1 2 20 10
114
Hint
Constraints:
- For 10% of the testdata: , .
- Additionally, for 20% of the testdata: , , .
- For all testdata: , , , , , . The input guarantees the answer does not exceed a 32-bit signed integer.
Translated by ChatGPT 5
京公网安备 11011102002149号