{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Wshxzt is a lovely girl. She likes apple very much. One day HX takes her to an apple tree. There are N nodes in the tree. Each node has an amount of apples. Wshxzt starts her happy trip at one node. She can eat up all the apples in the nodes she reaches. HX is a kind guy. He knows that eating too many can make the lovely girl become fat. So he doesn’t allow Wshxzt to go more than K steps in the tree. It costs one step when she goes from one node to another adjacent node. Wshxzt likes apple very much. So she wants to eat as many as she can. Can you tell how many apples she can eat in at most K steps.\n \u003c/div\u003e\n\u003cbr\u003e一颗树,n个点(1-n),n-1条边,每个点上有一个权值,求从1出发,走k步,最多能遍历到的权值。"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n There are several test cases in the input \n \u003cbr\u003eEach test case contains three parts. \n \u003cbr\u003eThe first part is two numbers N K, whose meanings we have talked about just now. We denote the nodes by 1 2 ... N. Since it is a tree, each node can reach any other in only one route. (1\u0026lt;\u003dN\u0026lt;\u003d100, 0\u0026lt;\u003dK\u0026lt;\u003d200) \n \u003cbr\u003eThe second part contains N integers (All integers are nonnegative and not bigger than 1000). The ith number is the amount of apples in Node i. \n \u003cbr\u003eThe third part contains N-1 line. There are two numbers A,B in each line, meaning that Node A and Node B are adjacent. \n \u003cbr\u003eInput will be ended by the end of file. \n \u003cbr\u003e \n \u003cbr\u003eNote: Wshxzt starts at Node 1.\n \u003c/div\u003e\n\u003cbr\u003e多组数据\n\u003cbr\u003e第一行两个整数N,K 1\u003c\u003dN\u003c\u003d100,0\u003c\u003dk\u003c\u003d200\n\u003cbr\u003e第二行N个整数,0\u003c\u003dx\u003c\u003d1000表示每个节点中苹果的数量\n\u003cbr\u003e最后N-1行描述两个点相连\n"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n For each test case, output the maximal numbers of apples Wshxzt can eat at a line.\n \u003c/div\u003e\n\u003cbr\u003e输出最大能遍历到的权值"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2 1 \n0 11\n1 2\n3 2\n0 1 2\n1 2\n1 3\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e11\n2\n\u003c/pre\u003e"}}]}