#P1642. 规划

规划

Description

There are NN factories connected by N1N - 1 roads, and any two factories are reachable. Each factory has a production value and a pollution value. Now we plan to demolish MM 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 N,MN, M representing the number of factories and the number to demolish.

The second line contains NN positive integers wiw_i, representing the production of each factory.

The third line contains NN positive integers cic_i, representing the pollution of each factory.

Then follow N1N - 1 lines. Each line contains two positive integers a,ba, b (1a,bN1 \le a, b \le N) indicating that aa and bb 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, 1<N<1001 < N < 100, 1M<N1 \le M < N, 1wi100001 \le w_i \le 10000, and 1ci100001 \le c_i \le 10000.

Translated by ChatGPT 5