{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eflymouse’s sister wc is very capable at sports and her favorite event is walking race. Chasing after the championship in an important competition, she comes to a training center to attend a training course. The center has \u003ci\u003eN\u003c/i\u003e check-points numbered 1 through \u003ci\u003eN\u003c/i\u003e. Some pairs of check-points are directly connected by two-way paths. The check-points and the paths form exactly a tree-like structure. The course lasts \u003ci\u003eN\u003c/i\u003e days. On the \u003ci\u003ei\u003c/i\u003e-th day, wc picks check-point \u003ci\u003ei\u003c/i\u003e as the starting point and chooses another check-point as the finishing point and walks along the only simple path between the two points for the day’s training. Her choice of finishing point will make it that the resulting path will be the longest among those of all possible choices.\u003c/p\u003e\u003cp\u003eAfter every day’s training, flymouse will do a physical examination from which data will obtained and analyzed to help wc’s future training be better instructed. In order to make the results reliable, flymouse is not using data all from \u003ci\u003eN\u003c/i\u003e days for analysis. flymouse’s model for analysis requires data from a series of consecutive days during which the difference between the longest and the shortest distances wc walks cannot exceed a bound \u003ci\u003eM\u003c/i\u003e. The longer the series is, the more accurate the results are. flymouse wants to know the number of days in such a longest series. Can you do the job for him?\u003c/p\u003e\u003c/span\u003e\u003c/div\u003e\n求1~n 在树上的最远距离d[i] , 1\u003c\u003di\u003c\u003dn; 然后求出d数组里最长区间长度且满足区间最大值-最小值\u003c\u003dm;"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe input contains a single test case. The test case starts with a line containing the integers \u003ci\u003eN\u003c/i\u003e (\u003ci\u003eN\u003c/i\u003e ≤ 10\u003csup\u003e6\u003c/sup\u003e) and \u003ci\u003eM\u003c/i\u003e (\u003ci\u003eM\u003c/i\u003e \u0026lt; 10\u003csup\u003e9\u003c/sup\u003e). Then follow \u003ci\u003eN\u003c/i\u003e − 1 lines, each containing two integers \u003ci\u003ef\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003ed\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (i \u003d 1, 2, …, \u003ci\u003eN\u003c/i\u003e − 1), meaning the check-points \u003ci\u003ei\u003c/i\u003e + 1 and \u003ci\u003ef\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e are connected by a path of length \u003ci\u003ed\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e.\u003c/p\u003e\u003c/span\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cp\u003eOutput one line with only the desired number of days in the longest series.\u003c/p\u003e\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3 2\n1 1\n1 3\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cp\u003eExplanation for the sample:\u003c/p\u003e\u003cp\u003eThere are three check-points. Two paths of lengths 1 and 3 connect check-points 2 and 3 to check-point 1. The three paths along with wc walks are 1-3, 2-1-3 and 3-1-2. And their lengths are 3, 4 and 4. Therefore data from all three days can be used for analysis.\u003c/p\u003e\u003c/div\u003e"}}]}