You are not logged in. Please login at www.codechef.com to post your questions!

×

IOC - Editorial

PROBLEM LINK:

Practice
Contest

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

DIFFICULTY:

EASY

PREREQUISITES

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.

horizontal cut

vertical cut

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.

asked 25 Apr '18, 22:47

jatin_cpp's gravatar image

5★jatin_cpp
41
accept rate: 0%

edited 26 Apr '18, 16:43

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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