![]() | ||||
Online Judge | Problem Set | Authors | Online Contests | User |
---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Fire Time Limit:2000MS Memory Limit:65536K Description Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so the government decided to build some firehouses in some cities. Build a firehouse in city K cost W(K). W for different cities may be different. If there is not firehouse in city K, the distance between it and the nearest city which has a firehouse, can¡¯t be more than D(K). D for different cities also may be different. To save money, the government wants you to calculate the minimum cost to build firehouses. Input
The first line of input contains a single integer T representing the number of test cases. The following T blocks each represents a test case.
Output For each test case output the minimum cost on a single line. Sample Input
Sample Output
Source POJ Monthly,Lou Tiancheng |
[Submit] [Go Back] [Status] [Discuss]
All Copyright Reserved 2003
Any problem, Please Contact Administrator