Electricity
면접 대비시간 제한40초메모리 제한1024 MB
각 정점에 용량이 있는 트리에서 시작 정점 하나를 골랐을 때, 용량이 더 작은 이웃으로만 전기가 전파된다. 전기를 받는 정점 수의 최댓값을 구한다.
문제
Ben works as an engineer in a city with electric junctions. These junctions form a network and can be visualised as a connected graph with vertices and edges. The city is facing a power outage, due to which none of the junctions are receiving electricity, and Ben is in charge of handling the situation.
Each junction has a fixed electric capacity. is the electric capacity of the -th junction. Due to resource constraints, Ben can provide electricity to only one junction, but other junctions can receive electricity depending on their connections and capacities. If the -th junction receives electricity, then it will also get transmitted to all the junctions directly connected to the -th junction whose capacity is strictly less than . Transmission stops if no eligible junction is present. Help Ben determine the maximum number of junctions that can receive electricity.
입력
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains an integer which represents the number of junctions in the city.
The next line contains integers. The -th integer is , which is the electric capacity of the -th junction.
The next lines each contain two integers and , meaning that the junctions and are directly connected to each other.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the maximum number of junctions that can receive electricity.
제한
- .
- , for all .
- , for all .
- All the junctions are part of a single connected network.