Has anyone else had trouble with timelimits here? If yes, how have you overcome them?
My approach is to order the boxes in such a way that box1 appears after box2 whenever one can stack box1 on box2. To take care of different rotations, I store three versions of the box (one for each side as height; width is always the larger remaining one, length always the smaller remaining one).
I then calculate for each box, what stack height we can maximally reach if the current box is the very bottom one (summing up current box's height and the maximum stack height of all smaller boxes).
This way, I should have a running time of O(n^2) which should be fine considering that n <= 1000.