Can someone please tell me where i am going wrong? I am getting WA.
Following is the link to my code :
Thanks a lot.
Can someone please tell me where i am going wrong? I am getting WA.
Following is the link to my code :
Thanks a lot.
You need to sort the array of pies and racks first. The rest of your logic was almost correct.
Here is the corrected code - http://www.codechef.com/viewsolution/3927466
That’s okay.
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.
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++.
thanks a lot!