#P6074. 最小路径
最小路径
Description
You are given a tree with nodes. Each node has two weights and . Find a simple path of length such that is minimized. If there is no solution, output .
Input Format
The first line contains two positive integers and .
The second line contains positive integers .
The third line contains positive integers .
The following lines each contain two positive integers , which are the two endpoints of an edge.
Output Format
Output the minimum value, rounded to two decimal places.
3 1
2 3 3
6 6 6
1 2
2 3
0.42
9 2
9 4 4 1 6 5 1 9 5
8 3 3 1 5 4 1 8 4
1 2
2 3
3 4
3 5
1 6
6 7
7 8
6 9
1.15
Hint
Subtask 1 ( points): , , .
Subtask 2 ( points): , , .
Subtask 3 ( points): , , .
For of the testdata: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号