×

# WA in Cook Off 54 : Abhijeet and rectangles

 0 I understood the editorial to the question but why does my approach not work? My approach- Sort the lengths and breadth in two different lists and maintain pointers to the first element of each of them. Let's call these two lists l and b, and the two pointers i and j for our convenience. Let A1 = l[i] * b[j+1] and A2 = l[i+1] * b[j] (i.e. A1 = smallest length * second smallest breadth; A2 = second smallest length * smallest breadth) If A1 < A2 remove the rectangle with shortest length and mark it as removed else remove rectangle with shortest breadth and mark that as removed. My code Any help will be appreciated! asked 23 Jan '15, 00:55 32●4 accept rate: 11%

 1 What answer are you getting for this case... Ans should be 10!! 1 3 2 2 3 3 3 1 10  answered 23 Jan '15, 07:27 4★kunal361 6.0k●13●32●72 accept rate: 21% I am getting 9, the code removes the wrong rectangle. Got my mistake! Thanks! (24 Jan '15, 01:45)
 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:

×2,356
×849
×178
×4
×4

question asked: 23 Jan '15, 00:55

question was seen: 1,903 times

last updated: 24 Jan '15, 01:45