UpCoder is forming a team to build its new website, and you choose the members. There are n candidates, numbered 1 through n. The CEO is employee number 0. Every candidate was recommended by an employee with a smaller number. Besides the employee number, a candidate is described by a salary s, an expected productivity p, and the number r of the employee who recommended them.
You must put exactly k of the n candidates on the team. The total value of the team is the sum of the members' productivities divided by the sum of their salaries. A candidate may join the team only if the employee who recommended them is also on the team, or is the CEO. At least one member is therefore a candidate the CEO recommended. The CEO runs the business side of the company and does not count toward the k members.
Find the largest total value a team can reach under these rules.