Maximize total preserved credits by fortifying nodes in a tree.
Google operates a distributed infrastructure consisting of n interconnected compute nodes. The network forms a tree: there are exactly n - 1 bidirectional communication links and every node is reachable from every other node. Each node i initially contains credits[i] compute credits, which may be positive or negative. To prepare for a planned infrastructure migration, Google may fortify selected nodes. Fortifying a node does not change its own credits; instead, it consumes exactly d compute credits from each of its directly connected neighboring nodes to reinforce its infrastructure. A node may be fortified at most once, and neighboring nodes are allowed to have negative credits after deductions. After the migration, every fortified node remains active, every non-fortified node is decommissioned, and only the final credits of the active (fortified) nodes contribute to the total preserved credits. Determine the maximum total preserved compute credits that can be achieved by choosing an optimal set of nodes to fortify.
Community answers
Related courses


