×_7_12_2013 C: More happiness

Problem C: More happiness

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 1   Solved: 0
[ Submit][ Status][ Web Board]

Description

As you know, poor Xiaoming has been dreaming to go to Happyvalley for a long time. The good news is 
that today his mom finally agrees to take him there this weekend! 
In order to make his journey in Happyvalley happier, Xiaoming found a map of Happyvalley to design a 
good path. Happyvalley has N scenic spots and there are roads between them. Xiaoming found that there is 
only one way between each two spots. In other words, the N spots and roads between them form a “tree”.  
Xiaoming can start his journey from arbitrary scenic spot. It takes Ci minutes to walk from one end to the 
other end on the ith road. Xiaoming knows that he can only stay in Happyvalley for only P minutes. 
However, he is uncertain of the time he may spend in each scenic spot. So he can only guess it.  
Given the information of Happyvalley and the total time P minutes, also, with the time X Xiaoming guess he 
would spend in each spot, can you tell Xiaoming the maximum number of spots he can stay for X minutes? 
Note that each spot should be count only once. 

Input

The first line of the input is T (no more than 10), which stands for the number of test cases you need to 
solve.  
On the first line of each test case, there are two integers giving the number N (no more than 200) of scenic 
spots in Happyvalley and the total time P (no more than 2000000) Xiaoming can stay. The following N-1 
lines state the roads in the form of “a b c” which means it takes c minutes to walk from spot a to spot b or 
from b to a (1 <= a, b <= N, 1 <= c <= 10000). 
Then an integer Q (no more than 10000) in a single line is the number of queries Xiaoming asks you. Each 
of the next N lines gives a number X (no more than 10000) representing the time Xiaoming guess.

Output

Output the maximum number of spots he can get based on each guess of Xiaoming. Separate each test case 
with a blank line. 

Sample Input

2 3 10 1 2 2 2 3 1 3 10 2 4 6 15 1 2 2 1 3 1 2 6 3 5 3 5 3 4 3 4 1 2 3 100

Sample Output

1 3 2 5 4 3 0



转载于:https://my.oschina.net/dianpaopao/blog/145703

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值