Let's write some equations.
Mingwei's distance from Town A after [tex]x[/tex] hours from 8:00 is [tex]45x[/tex].
Ali's distance from Town B after [tex]x[/tex] hours is [tex]30x-20[/tex], since he doesn't start walking for 40 minutes.
When Mingwei's distance is twice Ali's, they've met up (since their distance from Town A is twice their distance from Town B).
So, this gives [tex]45x=60x-40[/tex], so [tex]15x=40[/tex], so [tex]x=\frac{40}{15} = \frac{8}{3}[/tex], so the time is 10:40.
After [tex]\frac83[/tex] hours, Mingwei has traveled [tex]45 * 8 / 3 = 120[/tex] kilometers while Ali has traveled sixty, so the distance between the towns is [tex]180[/tex] kilometers.