finish. Car i starts at mark start[i] and drives at speed[i] marks per hour.
The road has a single lane, so no overtaking. When a car catches up with the one ahead, they continue together at the speed of the front car, forming a convoy. A lone car is a convoy too. A car that catches a convoy exactly at mark finish counts as part of it.
Return how many convoys reach the finish.finish=20, start=[2, 14, 10, 0], speed=[3, 1, 4, 2] → 2
The car at 14 needs 6 hours; the one at 10 needs 2.5 and catches it exactly at the finish. The car at 2 would need 6 hours too, so it joins them. The car at 0 needs 10 hours and arrives alone. That is 2 convoys.
finish=9, start=[1, 5], speed=[1, 4] → 2
The front car arrives after 1 hour, the rear one after 8. Nobody catches up: 2 convoys.
finish=50, start=[7], speed=[10] → 1
start[i] are distinctfinish=20, start=[2, 14, 10, 0], speed=[3, 1, 4, 2]
2
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.