IOI_AK_TLR @ 2023-08-31 19:28:01
#include <bits/stdc++.h>
using namespace std;
const int N1=1e6+10,N2=1e5+10;
int a[N1],n,m,d;
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
{
scanf("%d",&d);
int L=1,R=n,mid;
while(L<R)
{
mid=(L+R)/2;
if(a[mid]>=d)
R=mid-1;
else
L=mid+1;
}
if(a[L]==d)
printf("%d ",L);
else printf("%d ",-1);
}
return 0;
}
by Henry2012 @ 2023-08-31 19:43:12
输出没换行