CF1556H DIY Tree
Description
William really likes puzzle kits. For one of his birthdays, his friends gifted him a complete undirected edge-weighted graph consisting of $ n $ vertices.
He wants to build a spanning tree of this graph, such that for the first $ k $ vertices the following condition is satisfied: the degree of a vertex with index $ i $ does not exceed $ d_i $ . Vertices from $ k + 1 $ to $ n $ may have any degree.
William wants you to find the minimum weight of a spanning tree that satisfies all the conditions.
A spanning tree is a subset of edges of a graph that forms a tree on all $ n $ vertices of the graph. The weight of a spanning tree is defined as the sum of weights of all the edges included in a spanning tree.
Input Format
N/A
Output Format
N/A