Box Stacking Problem in CPP