------
## 最终结论
```python
from collections import defaultdict, deque

def numOfMinutes(n, headID, manager, informTime):
    # Build the tree structure using adjacency list
    subordinates = defaultdict(list)
    for i in range(n):
        if manager[i] != -1:
            subordinates[manager[i]].append(i)

    # Initialize the queue with the headID and current time as 0
    queue = deque([(headID, 0)])  # (current_employee, current_time)
    max_time = 0

    # Process each employee in the queue, updating the maximum time and enqueueing their subordinates with updated time
    while queue:
        current_employee, current_time = queue.popleft()
        max_time = max(max_time, current_time)

        for subordinate in subordinates[current_employee]:
            queue.append((subordinate, current_time + informTime[current_employee]))

    # Return the maximum time taken to inform all employees
    return max_time

# Example usage:
# print(numOfMinutes(1, 0, [-1], [0]))  # Output: 0
# print(numOfMinutes(6, 2, [2,2,-1,2,2,2], [0,0,1,0,0,0]))  # Output: 1
# print(numOfMinutes(7, 6, [1,2,3,4,5,6,-1], [0,6,5,4,3,2,1]))  # Output: 21
# print(numOfMinutes(15, 0, [-1,0,0,1,1,,2,,2,,3,,3,,4,,4,,5,,5,,6,,6], [1,,1,,1,,1,,1,,1,,0,,0,,0,,0,,0])) # Output:3
# print(numOfMinutes(4,,2,[3,,3,-1,,2],[0,,0,,162,,914])) # Output:1076
```