Solution for a bipartite Euclidean traveling-salesman problem in one dimension