#C7513. Interstellar Postman Delivery Time
Interstellar Postman Delivery Time
Interstellar Postman Delivery Time
An interstellar postman is assigned the task of delivering packages to a network of planets. Each planet has a certain number of packages waiting, and although the planets are connected by various routes, the delivery time is constrained by the planet with the highest number of packages. In other words, the minimum time required for complete delivery is equal to the maximum number of packages present on any single planet.
You will be given multiple test cases. For each test case, the first number represents the number of planets (N). The next line contains N space-separated integers representing the number of packages waiting on each planet. Following that, there are N lines where each line lists the connected planets (0-indexed) for the corresponding planet. Your task is to compute, for each test case, the maximum number of packages found on any planet.
Note: The network connections are provided as part of the input but do not affect the delivery time.
inputFormat
The input is read from standard input (stdin) and has the following format:
T N p1 p2 ... pN c1 c2 ... cN [Repeat the above block for T test cases]
Where:
T
is the number of test cases.N
is the number of planets in the test case.- The next line has
N
integers representing the number of packages on each planet. - Each of the following
N
lines lists the 0-indexed neighbors (space-separated integers) of that planet. These lines can have variable numbers of integers.
outputFormat
For each test case output a single line containing the minimum delivery time, which is simply the maximum number of packages on any planet.
The output should be printed to standard output (stdout).
## sample2
3
5 0 0
1 2
0 2
0 1
4
10 1 2 1
1 2 3
0 2
0 1 3
0 2
5
10
</p>