{"raw_statement":[{"iden":"statement","content":"You are given a tree consisting of N nodes and N - 1 weighted edges. You want to remove exactly M edges so that node 1 will remain in a component with exactly K nodes, while minimizing the sum of costs of the removed edges.\n\nThe first line of input will contain three positive integers N(1 ≤ N < 75), M(1 ≤ M < N) and K(1 ≤ K ≤ N). The following N - 1 lines will each contain 3 numbers x y c, describing an edge between nodes x and y of cost c.\n\nThe first and only line of your output should contain one integer representing the minimum cost required, or  - 1 if there is no valid solution.\n\n"},{"iden":"input","content":"The first line of input will contain three positive integers N(1 ≤ N < 75), M(1 ≤ M < N) and K(1 ≤ K ≤ N). The following N - 1 lines will each contain 3 numbers x y c, describing an edge between nodes x and y of cost c."},{"iden":"output","content":"The first and only line of your output should contain one integer representing the minimum cost required, or  - 1 if there is no valid solution."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T = (V, E) $ be a tree with $ |V| = N $ nodes and $ |E| = N - 1 $ weighted edges.  \nLet $ w: E \\to \\mathbb{R}^+ $ be the edge cost function.  \nLet $ M, K \\in \\mathbb{Z}^+ $ with $ 1 \\leq M < N $, $ 1 \\leq K \\leq N $.  \n\n**Constraints**  \n1. Remove exactly $ M $ edges from $ T $.  \n2. After removal, the connected component containing node $ 1 $ must contain exactly $ K $ nodes.  \n3. The remaining graph consists of $ M+1 $ connected components.  \n\n**Objective**  \nMinimize the total cost of the removed edges:  \n$$\n\\min \\sum_{e \\in R} w(e)\n$$  \nwhere $ R \\subseteq E $, $ |R| = M $, and the component containing node $ 1 $ in $ T \\setminus R $ has size $ K $.  \nIf no such $ R $ exists, output $ -1 $.","simple_statement":"You are given a tree with N nodes and N-1 weighted edges. Remove exactly M edges so that the component containing node 1 has exactly K nodes. Minimize the total cost of removed edges. Output the minimum cost, or -1 if impossible.","has_page_source":false}