Electricity

아직 제출이 없습니다시간 제한40초메모리 제한1024 MB

문제

Ben works as an engineer in a city with N\mathbf{N} electric junctions. These junctions form a network and can be visualised as a connected graph with N\mathbf{N} vertices and N1\mathbf{N}-1 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. A_i\mathbf{A\_i} is the electric capacity of the ii-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 ii-th junction receives electricity, then it will also get transmitted to all the junctions directly connected to the ii-th junction whose capacity is strictly less than A_i\mathbf{A\_i}. 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, T\mathbf{T}. T\mathbf{T} test cases follow.

The first line of each test case contains an integer N\mathbf{N} which represents the number of junctions in the city.

The next line contains N\mathbf{N} integers. The ii-th integer is A_i\mathbf{A\_i}, which is the electric capacity of the ii-th junction.

The next N1\mathbf{N}-1 lines each contain two integers X_i\mathbf{X\_i} and Y_i\mathbf{Y\_i}, meaning that the junctions X_i\mathbf{X\_i} and Y_i\mathbf{Y\_i} are directly connected to each other.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum number of junctions that can receive electricity.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 1A_i1091 \le \mathbf{A\_i} \le 10^9, for all ii.
  • 1X_i,Y_iN1 \le \mathbf{X\_i}, \mathbf{Y\_i} \le \mathbf{N}, for all ii.
  • All the junctions are part of a single connected network.