BonVoyageBon VoyageBonVoyage is a strong rowing team. As one of the three members, Apollo wants to help his teammates to solve tree problems faster. He plans to leave a tree problem to his teammates every day to train them. If his teammates failed to solve it, as a punishment, they would have to take turns to pay Apollo for a day's meal. Today is the first day for them to execute the plan. Facing Apollo's tough problem, his teammates decide to ask you for help. In return, they promise to give you half of the money that is saved for not having to pay Apollo's meal. Smart as you are, could you help them solve the following problem and get this huge sum ?
Bon VoyageBon VoyageBon Voyage is a strong rowing team. As one of the three members, Apollo wants to help his teammates to solve tree problems faster. He plans to leave a tree problem to his teammates every day to train them. If his teammates failed to solve it, as a punishment, they would have to take turns to pay Apollo for a day's meal. Today is the first day for them to execute the plan. Facing Apollo's tough problem, his teammates decide to ask you for help. In return, they promise to give you half of the money that is saved for not having to pay Apollo's meal. Smart as you are, could you help them solve the following problem and get this huge sum (Apollo eats a lot)? Given a tree with n nodes numbered from 1 to n. The node 1 is the root. Each node i has an associated value v[i]. Denote K as the distance coefficient, and W as the target value. Denote the depth of node i as dep[i]. The depth of node 1 (dep[1]) is 1. For each node, its lili valuelili valuelili value is defined as follows: For some array c, let's denote a lili sequence as a sequence of indices p1,p2,...,plp_1, p_2, ... , p_lp1,p2,...,pl such that 1≤p1