#include<bits/stdc++.h>
using namespace std;
int main()
{
int ary[50005],temp[50005],q;
int n;
scanf("%d",&n);
for(int i=0; i<n; i++)scanf("%d",&ary[i]);
int len=0;
for(int i=0; i<n; i++)
{
if(i==0) temp[len++]=ary[i];
else
{
if (ary[i]!=ary[i-1]) temp[len++]=ary[i];
}
}
cin>>q;
//for(int i=0; i<len; i++) cout<<temp[i]<<endl;
for(int i=0; i<q; i++)
{
int target;
scanf("%d",&target);
if(target<temp[0])
{
printf("X %d\n",temp[0]);
continue;
}
if(target==temp[0])
{
printf("X %d\n",temp[1]);
continue;
}
if(target==temp[len-1])
{
printf("%d X\n",temp[len-2]);
continue;
}
if(target>temp[len-1])
{
printf("%d X\n",temp[len-1]);
continue;
}
int low=0,high=len-1,mid;
while(high-low!=1)
{
mid=(low+high)/2;
if(target==temp[mid])
{
low=mid-1;
high=mid+1;
break;
}
else if(target>temp[mid])low=mid;
else high=mid;
}
printf("%d %d\n",temp[low],temp[high]);
}
return 0;
}
using namespace std;
int main()
{
int ary[50005],temp[50005],q;
int n;
scanf("%d",&n);
for(int i=0; i<n; i++)scanf("%d",&ary[i]);
int len=0;
for(int i=0; i<n; i++)
{
if(i==0) temp[len++]=ary[i];
else
{
if (ary[i]!=ary[i-1]) temp[len++]=ary[i];
}
}
cin>>q;
//for(int i=0; i<len; i++) cout<<temp[i]<<endl;
for(int i=0; i<q; i++)
{
int target;
scanf("%d",&target);
if(target<temp[0])
{
printf("X %d\n",temp[0]);
continue;
}
if(target==temp[0])
{
printf("X %d\n",temp[1]);
continue;
}
if(target==temp[len-1])
{
printf("%d X\n",temp[len-2]);
continue;
}
if(target>temp[len-1])
{
printf("%d X\n",temp[len-1]);
continue;
}
int low=0,high=len-1,mid;
while(high-low!=1)
{
mid=(low+high)/2;
if(target==temp[mid])
{
low=mid-1;
high=mid+1;
break;
}
else if(target>temp[mid])low=mid;
else high=mid;
}
printf("%d %d\n",temp[low],temp[high]);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন