2072Divid Regions

2072   Divid Regions

题目描述

An old country has n cities, which are numbered from 1 to N. Cities are connected by road, and there is exact one path between two different cities.In order to manage the country, the king decide to divide the country into k regions,each region may contain several citys, and all the cities of a region can get to the other cities in this region by only through cities of the region.We can think that the number of the residents of city i is Xi , and the King wants to make the number of resident of evevy region as large as possible(equal means the least number as large as possible).As his most intelligent minister,can you help the King to divid the regions?

输入格式:

The first line contains two integer N ( 0 < N ≤ 10000) and k( k ≤ N ), means the number of citiy and the number of  region.the second line contains N inerger Xi ( 1 ≤ Xi ≤ 100 ),means the number of residents of city i, then the flowing n-1 lines,u,v (1 ≤ u, v ≤ N) ,which means the is a road between city u and city v.

输出格式:

Output the largest number of resident that every region can have.

输入样例 复制
6 2
1 5 5 1 1 1
1 2
1 3
1 4
4 5
4 6
输出样例 复制
5

说明

1
2
通过提交
时空限制1000ms/128mb
题目来源
评测方式在线评测
题目类型
难        度