Hello,

First and foremost, The problem is really interesting and keep on innovating.

Although, I was able to pass only 7 test cases, I’m curious to know the algorithm.

So, can you please tell me the way you have constructed.

Keep Innovating

Thank you

Here’s my code; I someone can help me to figure out the bug, please!

```
// the program below works fine
// for all test cases except
// Test Cases: 6,9,10
// Reason: for 6; output: 48 but answer:49
// Reason: for 9; output: 0 but answer:6
// Reason: for 10; output: 88 but answer: 74
import sys
import math
//max_speed_original km/h
max_speed_o = int(input())
light_count = int(input())
// max_speed m/s
max_speed = max_speed_o * 5/18
dur = [] //duration
dist = [] //distance
// store the values in a list
for i in range(light_count):
distance, duration = [int(j) for j in input().split()]
dur.append(duration)
dist.append(distance)
// min time for the closest light
t_min_i = dist[0]/max_speed
// approx int val
t = math.floor(t_min_i)
while True:
isGreen = False
#iterate through each
for i in range(light_count):
// using point slope method to find the intercept
if int((dist[i]/dist[0]*t)//dur[i]) % 2 == 0:
isGreen = True
else:
isGreen = False
break
if isGreen:break
t += 1
if isGreen:
//s = speed
s = (dist[0]/t)
// check if speed > max_speed m/s
s = max_speed if s>max_speed else s
//print('Floor km/h:',math.floor(s* (18/5)))
s = math.floor(s* (18/5))
// check if speed > max_speed km/h
s = max_speed_o if s>max_speed_o else s
print(s)
//-----------End -----------
```