Optimal distance-based clustering for one-dimensional data