Correct option is B
Speed of the first car = 40 m/s = 40/1000 km/s = 0.04 km/s
Speed of the second car = 50 m/s = 50/1000 km/s = 0.05 km/s
Since the cars are moving towards each other, their speeds add up.
Relative speed = 0.04 km/s + 0.05 km/s = 0.09 km/s
Time = Distance / Relative speed
Time = 45 km / 0.09 km/s = 500 seconds