N cakes are given. Cut k of them parallel to any edge to maximise the sum of perimeters of rectangles.
We have a total of N cakes, each ith cake having a length li and breadth bi (1 <= i <= n).
For any ith cake, to divide it into 2 rectangles and maximise the perimeter, we have to cut it parallel to Xi = max(li,bi). The extra perimeter so formed will be Yi = 2 * Xi.
So we store the extra perimeters each cake gives, sort them and pick the k maximum cakes from them to cut.