×

# IOC - Editorial

Author: Jarin Gupta
Tester: Aanya Jindal
Editorialist: Gaurav Aggarwal

EASY

Sorting

# PROBLEM:

N cakes are given. Cut k of them parallel to any edge to maximise the sum of perimeters of rectangles.

# EXPLANATION:

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.

# AUTHOR'S AND TESTER'S SOLUTIONS:

Author's solution can be found here.
Tester's solution can be found here.

41
accept rate: 0%

19.8k350498541

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,852
×3,820
×1,024
×801
×125
×10

question asked: 25 Apr '18, 22:47

question was seen: 190 times

last updated: 26 Apr '18, 16:43