AC solution

Silly mistake fixed. Didn't need to prune further if distance is above the time.