iiihhh @ 2024-06-08 17:16:15
#include<iostream>
#include<stdio.h>
using namespace std;
long long n,m;
long long a[100005];
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++){
int k;
cin>>k;
int l=1;
int r=n;
while(l<r){
int mid=(l+r)/2;
/*if(a[mid]>k)r=mid-1;
else l=mid;
*/
if(a[mid]>=k)r=mid;
else l=mid+1;
}
if(a[l]==k)printf("%d ",l);
else printf("%d ",-1);
}
return 0;
}
by Free_Duck @ 2024-06-08 17:38:12