#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void quicksort(int x[10],int first,int last)
{;}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,q;
cin>>n>>q;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
while(q--)
{
ll key;
cin>>key;
ll low=0;
ll high =n-1;
ll flag=0;
while(low<=high)
{
ll mid = (low + high) /2;
if(a[mid]<key)
{
low=mid+1;
}
else if(a[mid]>key)
{
high=mid-1;
}
else
{ flag=1;
break;
}
}
if(flag==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
using namespace std;
#define ll long long int
void quicksort(int x[10],int first,int last)
{;}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,q;
cin>>n>>q;
ll a[n];
for(ll i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
while(q--)
{
ll key;
cin>>key;
ll low=0;
ll high =n-1;
ll flag=0;
while(low<=high)
{
ll mid = (low + high) /2;
if(a[mid]<key)
{
low=mid+1;
}
else if(a[mid]>key)
{
high=mid-1;
}
else
{ flag=1;
break;
}
}
if(flag==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
This comment has been removed by the author.
ReplyDeletei am not getting output for this
ReplyDelete