{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"给出N个节点,N-1条边的树,给出每条边权值w,现在要求切断其中一些边,使得任意一个叶子没有走到祖先(1)的路\n给出m,要求切断的边的总权值小于等于m,求所有的方案中切断的最大的权最小的值"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of several test cases. \n\u003cbr\u003eThe first line of each test case contains 2 integers: n(n\u0026lt;\u003d1000)m(m\u0026lt;\u003d1000000). \n\u003cbr\u003eEach of the following N-1 lines is of the form: \n\u003cbr\u003eai bi wi \n\u003cbr\u003eIt means there’s one route from ai to bi(undirected) and it takes wi cost to cut off the route with the device. \n\u003cbr\u003e(1\u0026lt;\u003dai,bi\u0026lt;\u003dn,1\u0026lt;\u003dwi\u0026lt;\u003d1000) \n\u003cbr\u003eThe input ends with n\u003dm\u003d0. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Each case should output one integer, the minimal possible upper limit power of your device to finish your task. \n\u003cbr\u003eIf there is no way to finish the task, output -1."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5 5\n1 3 2\n1 4 3\n3 5 5\n4 2 6\n0 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e3\u003c/pre\u003e"}}]}