#P4469. [SCOI2007] 最优驾车
[SCOI2007] 最优驾车
Description
There are north–south two-way streets and east–west two-way streets forming a grid. The distance between any two adjacent streets (regardless of orientation) is miles. The southwest corner intersection has coordinates , and the northeast corner is . At any intersection, you may change direction arbitrarily. Each street has its own speed limit, which applies to the entire street regardless of travel direction.
Your task is to drive from intersection to . You may change speed only at intersections; you must not violate the speed limit of the street you are currently on; you may only travel along paths of minimal length; and the total travel time must lie within the closed interval . Speed is measured in miles per hour and must be a positive multiple of . If the speed is , then the miles per gallon is .
Input Format
- The first line contains two integers .
- The second line contains positive integers, giving the speed limits of the east–west streets from south to north.
- The third line contains positive integers, giving the speed limits of the north–south streets from west to east.
- The fourth line contains six integers .
Output Format
If there is no solution, output No.
Otherwise, output two lines describing, respectively, the earliest-arrival plan (if multiple, choose the most fuel-efficient among them) and the most fuel-efficient plan (if multiple, choose the earliest-arrival among them). Each plan is represented by two numbers: the arrival time in minutes (ceiling to the next integer), and the fuel consumption in gallons (rounded to two decimal places).
6 20
30 40 50 50 50 50
50 50 50 50 50 40
1 1 6 6 300 320
300 6.25
318 5.60
8 2
10 20 20 30 10 20 10 10
10 20 20 30 10 20 10 20
6 8 2 4 10 39
No
Hint
In Sample 1, the fastest route travels at a constant speed of miles per hour, with a total distance of miles, so the time is hours. The miles per gallon is , so the fuel consumption is gallons.
The most fuel-efficient route first travels miles at miles per hour, then miles at miles per hour, for a fuel consumption of $120 / 32 + 80 / \bigl(80 - 0.03 \times 35 \times 35\bigr) = 5.60$ gallons. The route in the figure satisfies both plans (the second plan changes speed at ).

Constraints:
- 20% of the testdata satisfy: .
- 50% of the testdata satisfy: .
- 100% of the testdata satisfy: , , . Speed limits do not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号