#P1642. 规划
规划
Description
There are factories connected by roads, and any two factories are reachable. Each factory has a production value and a pollution value. Now we plan to demolish factories so that the remaining factories still form a single connected component and the value of total production divided by total pollution is maximized.
Input Format
The first line contains two integers representing the number of factories and the number to demolish.
The second line contains positive integers , representing the production of each factory.
The third line contains positive integers , representing the pollution of each factory.
Then follow lines. Each line contains two positive integers () indicating that and are connected.
Output Format
Output the maximum value of total production divided by total pollution, rounded to one decimal place.
3 2
2 3 4
1 1 1
1 2
2 3
4.0
Hint
Constraints
For all testdata, , , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号