Hi…In Find Me Problem it has to be said that a set of numbers will be inputted and a desired number will also be inputted to verify that it is among that array of number. If that desired number is present print 1 otherwise -1.

My code is given below…whats the problem with my code,

#include<bits/stdc++.h>

using namespace std;

int main()

{

int a,b,i,c[100],d=0,first,last,mid;

cin>>a>>b;

for(i=1;i<=a ;i++)

{

cin>>c[i];

}

for(i=1;i<=a ;i++)

{

first=1;

last=a;

while(first<=last)

{

mid=(first+last)/2;

if(b==c[mid])

{

d=1;

break;

}

else if(b<c[mid])

{

last=mid-1;

}

else

{

first=mid+1;

}

}

}

if(d==0)

{

cout<<"-1"<<endl;

}

else

cout<<“1”<<endl;

}

i have found it clear and no problem in finding correct output. Although the submission judge said answer is wrong. PLzzz help me