robots[i] = [position, speed]: robot i starts position metres from the start of the rail and moves at speed m/s. The robots are listed in increasing order of starting position, and all positions are distinct. Treat the robots as points.
When a robot reaches the one directly ahead of it, they lock together and keep moving as one, at the speed of the slowest robot in the group.
Return an array whose i-th element is the time in seconds at which robot i reaches the robot directly ahead of it, or -1 if that never happens. Answers within 10⁻⁵ of the exact value are accepted.robots=[[2, 3], [5, 1], [6, 2]] → [1.5, -1, -1]
Robot 0 reaches robot 1 after (5 − 2) / (3 − 1) = 1.5 seconds. Robot 1 is slower than robot 2 and never reaches it, and robot 2 has nobody ahead, so both get -1.
robots=[[1, 4], [3, 3], [4, 1]] → [1.0, 0.5, -1]
Robot 1 reaches robot 2 after 0.5 s, and from then on they move together at speed 1. Robot 0 would need 2 s to reach robot 1 at its old speed, but it has slowed down: they actually meet after 1 second, at position 5.
robots=[[10, 7]] → [-1]
robots=[[2, 3], [5, 1], [6, 2]]
[1.5, -1, -1]
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.