ELPHANT - Wrong Answer

Can someone please tell me what am overlooking in my code? It passes all the test cases given in the example but still gives a wrong answer.Thanks in advance.

Here is the link to my code : http://ideone.com/uDhUti

The mistake I found is in Line 36 and Line 45

sort(b,b+i);

it should be

sort(b,b+i+1);

And

if((b[i]-b[s])>=l)

should be

if((b[i]-b[s])>l)

Since the camera can capture the elephants in interval of length L including the end points.

I think that should get you accepted.

1 Like

thanks a lot.it worked.