A tree is an undirected graph consisting of N nodes and (N-1) edges such
that there is exactly one path between each pair of nodes.
Khaled has a tree of N nodes rooted at node 1. He has M dollars and his
goal is to color the max number of nodes.
The price of coloring node i is A[i] dollars.
But there is a special offer, if Khaled has already colored at least C[i] nodes in the subtree of node i before coloring node 1, then he can choose to color node i using B[i] dollars. Note that Khaled has the freedom to use that offer
or to skip it.
Could you tell Khaled the max number of nodes he can color?
Input Format
The first line contains an integer, N, denoting the number of nodes in the
tree The next line contains an integer, M, denoting the number of dollars that Khaled has
Answers
Answer:
Did you mean: A tree is an undirected graph consisting of N nodes and (N-1) edges such that there is exactly one path between each pair of nodes. Khaled has a tree of N nodes rooted at node 1. He has M dollars and his goal is to color the max number of nodes. The price of coloring node i is A[i] dollars. But there is a special offer, if Khaled has already colored at least C[i] nodes in the subtree of node i before coloring node 1, then he can choose to color node i using B[i] dollars. Note that Khaled has the freedom to use that offer or to skip it. Could you tell Khaled the max number of nodes he can color? Input Format The first line contains an integer, N, denoting the number of nodes in the tree The next line contains an integer, N, denoting the number of dollars that Khaled has