At 2pm, the first boat is at the dock, and moves south at 20 km/h.
It's distance from the dock, in a vertical distance, can be expressed as 20t
At 2pm, the second boat is 5 km west of the dock. We know this, because an hour later it arrives at the dock.
It is moving towards the dock, so it's distance from the dock at time t = 5 - 5t in the horizontal direction.
Use pythagororean theorem to express the distance between the boats at time t:
d^2 = (5 - 5t)^2 + (20t)^2
d = sqrt [(5 - 5t)^2 + (20t)^2]
d = sqrt [25 - 50t + 25t^2 + 400t^2]
d = sqrt [25 - 50t + 425t^2]
Differentiate to find when the derivative equals zero in order to find the maximum.
d' = ( -50 + 850 t)/ [2 sqrt [(5 - 5t)^2 + (20t)^2]] = 0
t = 50/850 = 1/17