HBC202312Tree Partition题解

水水月牙 算法提高篇 40 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。

Bob has learned about all fancy algorithms on trees recently, so he decided to give you a little quiz. You are given an undirected tree with mathbf{N} N weighted nodes. You are to cut the tree into mathbf{K} K partitions (subtrees). In other words, you are to cut mathbf{K-1} K−1 edges from the tree so that the rest form a forest consisting of mathbf{K} K trees. The weight of a tree is defined as the sum of weights of all nodes in the tree. Your final score is the maximum weight of all partitions. Please find the best partition so that your final score is as small as possible.

标签: HBC202312Tree Partition题解