Computer Science, asked by KesavanCSE, 1 month ago


Formally, you need to find a subset of cities, S, such that the sum of P; over these cities is minimized, and the entire kingdom will be captured eventually if soldiers are parachuted into exactly these cities. You need to output this minimum sum. into exactly these cities. You need to output this minimum sum. Input format

The first line contains a single integer the number of cities in wonderland,

The ith of the next N-1 line contains two integers each, u, and v₁, which denote that there is an edge between Cities u; and v₁.

The next line contains N integers, P1, P2, ..., PN. Pi denotes the number of soldiers who have to parachute in, so as to capture City i on Day 0.

The next line contains N integers, C₁, C2,..., CN. C; denotes the number of neighbours of

City i that have to be captured for City i to be captured on the next day.

Output format

An integer representing the minimum total number of soldiers​

Attachments:

Answers

Answered by kc12
0

Formally, you need to find a subset of cities, S, such that the sum of P; over these cities is minimized, and the entire kingdom will be captured eventually if soldiers are parachuted into exactly these cities. You need to output this minimum sum. into exactly these cities. You need to output this minimum sum. Input format

The first line contains a single integer the number of cities in wonderland,

The ith of the next N-1 line contains two integers each, u, and v₁, which denote that there is an edge between Cities u; and v₁.

The next line contains N integers, P1, P2, ..., PN. Pi denotes the number of soldiers who have to parachute in, so as to capture City i on Day 0.

The next line contains N integers, C₁, C2,..., CN. C; denotes the number of neighbours of

City i that have to be captured for City i to be captured on the next day.

Output format

An integer representing the minimum total number of soldiers

Similar questions