codechef july long contest .

anyone would tell wats wrng in my code … its exactly the same as that of the editorial !!! the link of the solution is http://www.codechef.com/viewsolution/4326802 … any help is seriously welcomed

There is a minor mistake in your code. Read the problem careully, " In case both the dishes have equal scores, this round will be considered as a tie and nothing else will happen…"
So, instead of this:

void merge(int b,int c,int a[],int ans[])

{
if(a[b]>a[c])
ans[c]=b;
else
ans[b]=c;
}

Your code should be
void merge(int b,int c,int a[],int ans[])
{
if(a[b]>a[c])
ans[c]=b;
else if(a[b]<a[c])
ans[b]=c;
}

2 Likes

hmm thnks a lot !!! . i got dat .

@meintoo:very well higlighted by sanjeev1779, corner cases are very important and every of them must be handled, Happy learning :slight_smile: