A time-optimal algorithm for the estimation of contact distribution functions of random sets