Company: JK_Tech_13nov
Difficulty: medium
Family Tree Problem Description Given is a family tree where the root node is the elder member and leaf nodes are younger members. Each member is numbered from 1 to N. Each level of the tree represents one generation. Each member has a value A_i associated with him. If he has a positive value, he has A_i dollars of money. If it is a negative value, he has A_i dollars of loan. Each member of one generation can share their money with the members of the same generation who have loans to pay so that they ensure no one in that generation has a loan. Total wealth after loan repayment of every member of the higher generation can be given to the next lower generation members but during this process, the government takes X dollars from the total wealth as a hierarchical tax. The government of the state wants every member of all generations of the family to clear loans so they cannot put a high tax on the total wealth. Find X, the maximum amount as tax, ensuring no member of each generation hold