count employees numbered 0 to count - 1. The director is employee chief. For every employee i you know their direct boss boss_of[i]; for the director, boss_of[chief] = -1. The reporting lines form a tree rooted at the director.
The director wants to pass urgent news to everyone. They tell their direct reports, who tell theirs, and so on. Employee i needs relay_time[i] minutes to tell all of their direct reports: relay_time[i] minutes after i learns the news, all of them learn it at once and start passing it on right away.
Return how many minutes it takes until the whole company knows.
For an employee with no reports, relay_time[i] can be anything: they have nobody to tell, so it does not affect the answer.count=5, chief=0, boss_of=[-1, 0, 0, 1, 1], relay_time=[4, 3, 0, 0, 0] → 7
Director 0 needs 4 minutes to tell employees 1 and 2. Employee 1 then needs 3 more minutes to tell their reports 3 and 4. The last ones hear the news at minute 7.
count=3, chief=1, boss_of=[1, -1, 0], relay_time=[2, 1, 0] → 3
The chain is 1 → 0 → 2: 1 minute for the first step and 2 minutes for the second.
count=1, chief=0, boss_of=[-1], relay_time=[0] → 0
The company is just the director, so there is nobody to tell.
chiefcount=5, chief=0, boss_of=[-1, 0, 0, 1, 1], relay_time=[4, 3, 0, 0, 0]
7
Run checks the first 3 tests in your browser. Submit checks all 26 tests on the server, hidden ones included.