Nemo_ @ 2023-07-13 07:31:25
using namespace std;
int a[1000010];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int r=n,l=1;
while(m--)
{
int c,ans;
cin>>c;
int mid;
while(l<r)
{
mid=1+((r-l)>>1);
if(a[mid]>=c) r=mid-1;
else l=mid+1;
}
if(a[l]==c)
{
cout<<l<<" ";
}
else
{
cout<<-1<<' ';
}
}
return 0;
}
求教
by Nemo_ @ 2023-07-13 08:15:46
@Henry2012 过了,过了,谢谢dalao
by Henry2012 @ 2023-07-13 08:37:36
@Nemo_ 求互关
by Nemo_ @ 2023-07-13 11:17:56
@Henry2012 OKK