What was the journey?
Let the speed of RED ant is R & that of BLACK ant is B
Let time taken by them to meet be T.
Now we will apply the basic formula of distance:
Distance = Speed * Time.
The RED ant travels R T distance before meeting and 20 R after the meeting.
The BLACK ant travels B T distance before meeting and 5 B after the meeting.
Now as per the question,The distance traveled by RED ant before they both meet will be equal to the distance covered by BLACK ant after they meet. We can say the same for the vice versa case as well.
RT = 5B and BT = 20R i.e. B = 20R/T, putting in RT = 5B
R T = [20R/T] * 5
RT = 100R/T
T^2 = 100
T = 10.
Thus the RED ant will require 10 + 20 = 30 seconds to travel the distance.
And the BLACK ant will take 10 + 5 = 15 seconds to travel the distance.