A dynamic algorithm for placing rectangles without overlapping