Distance=speed×time, so time=distance/speed.
I assume that ⅓ and ½ refer to the distance AB, which we’ll call d km.
If J and Y are the times that Jimmy and Yuri take to go from A to B, the total time it takes Jimmy is:
The difference in time is Y-J=d(9/40-121/540)=(d/1080)(243-242)=d/1080.
Yuri took 30secs longer to get to B, and 30secs=1/120 hr.
Therefore d/1080=1/120, d=1080/120=9km.
The distance between the cities is 9km.