Computing minimum limited-capacity matching in one-dimensional space and for the points lying on two perpendicular lines

Let A = {a1,a2,...,as}, and B = {b1,b2,...,br} be two sets of points such that s + r = n. Also let CA = { 1, 2,..., s} and CB = { 1, 2,..., r} be the capacities of points in A and B. We define minimum limited capacity matching and call it MLC-matching that matches each point ai 2 A to at least one and at most i points in B and matches each bj 2 B to at least one and at most j points in A, for all i,j where 1 i s , 1 j r, such that sum of all the matching costs is minimized. Cost of matching ai 2 A to bj 2 B is equal to the distance between ai and bj. In one-dimensional space, we present an O(kn 2 ) algorithm to compute MLC-matching, where k = min{max( i, j),n}, which also works when points of A and B lie on two parallel lines and also on two unparallel lines, on one side of the cross point. We improved the algorithm to O(nlogn) for the points lying on two perpendicular lines.