| I SBC São Paulo Programming Marathon |
|---|
| Finished |
Newto went on a trip with his friends and brought several clothes to keep him warm, as he was warned that the place they were going to is very cold. Upon arriving there, he discovered that, in fact, the place is very hot. To make it worse, his friends turned on the air conditioning in some rooms of the house in heat mode at high temperatures, causing the place to become very warm.
He wants to solve this by moving through the rooms, turning on the air conditioning to lower the temperature and cool down the house. The house has $$$N$$$ rooms and $$$N-1$$$ corridors between them, such that there is a way to walk from any room to any other room. Newto starts in room $$$1$$$, representing the room he is currently in, and he wants to traverse the corridors the fewest number of times to ensure that the temperature of all rooms is less than or equal to a value $$$K$$$, which he believes is the ideal temperature at the moment. Upon arriving in a room, he can choose any temperature he desires in the range from $$$1$$$ to $$$99$$$ to be the new temperature of that room. As the path may be long, possibly involving passing through the same room more than once, Newto asks for your help to determine the minimum number of times he needs to traverse the corridors.
The first line contains two integers $$$N$$$ and $$$K$$$ $$$(1 \le N \le 10^5, 1 \le K \le 99)$$$, indicating the number of rooms in the house and the ideal temperature for Newto. The second line will have $$$N$$$ values $$$v_i$$$, the current temperature of the $$$i$$$-th room $$$(1 \le v_i \le 99)$$$. The next $$$N-1$$$ lines contain two integers $$$a_i$$$ and $$$b_i$$$ indicating that there is a corridor between rooms $$$a_i$$$ and $$$b_i$$$ $$$(1 \le a_i, b_i \le N$$$ and $$$a_i \ne b_i)$$$.
Your program must print a single value, the minimum number of times Newto must traverse corridors to achieve his goal.
5 4 3 7 5 2 6 1 2 1 3 3 4 3 5
4
4 35 30 31 32 33 1 2 2 3 3 4
0
Explanation of example 1:
Newton needs to cool down the rooms 2, 3 and 5. Possible path: 1 → 2 → 1 → 3 → 5.
| Name |
|---|


