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


COOLING - Wrong Answer

Can someone please tell me where i am going wrong? I am getting WA. Following is the link to my code :

Thanks a lot.

asked 20 May '14, 13:07

zoey's gravatar image

accept rate: 0%

You need to sort the array of pies and racks first. The rest of your logic was almost correct.

Here is the corrected code -


answered 20 May '14, 16:09

wittyceaser's gravatar image

accept rate: 16%

@wittyceaser I used bubble sort to sort the arrays as the input size is limited to 30.


answered 21 May '14, 16:25

zoey's gravatar image

accept rate: 0%

That's okay.

(21 May '14, 16:32) wittyceaser2★

You said that i need to sort the arrays which i did sort ,then why was it giving a wrong answer?

Thanks a lot for your help.

(21 May '14, 19:21) zoey2★

In the latter part of your code, you have written:

if(w[i]>m[j]) i++;

Basically, if the weight of a pie - i , is greater than the capacity of a rack - j (i.e., w[i] > m[j]), then that rack is not useful for us, so we'll try the next rack. Hence, j++ and not i++.

(21 May '14, 19:34) wittyceaser2★

thanks a lot!

(21 May '14, 22:37) zoey2★
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 20 May '14, 13:07

question was seen: 682 times

last updated: 21 May '14, 22:37