There is a set of $n$ rectangles with known dimensions. I want to find the smallest square that can fit all these rectangles within the following rules:
1) Rectangle sides must be parallel to $X$ or $Y$ axis.
2) Rotating rectangles is allowed.
3) Rectangles can touch but must not overlap.
I'm pretty sure no polynomial algorithm exists for such a problem, so I'm interested in some mathematical formula that gives a reasonable lowest bound of the square size.
Thanks.