CCF_NOI_wyz66 @ 2023-03-16 21:34:24
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int a[maxn],n,m,q;
int read(){
int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
int find(int x,int l,int r){
if(a[l] == x) return l;
if(l>=r) return -1;
int mid = l+((r-1)>>1);
if(a[mid] >= x) return find(x,l,mid);
else return find(x,mid+1,r);
}
int main(){
n = read(),m = read();
for(int i=1;i<=n;i++) a[i] = read();
for(int i=1;i<=m;i++){
q = read();
int ans = find(q,1,n+1);
printf("%d ",ans);
}
return 0;
}
by 初学者多高尚 @ 2023-03-16 21:40:59
好像改成
by jomy @ 2023-03-16 21:56:26
https://www.luogu.com.cn/record/104919741
RE?
by jomy @ 2023-03-16 21:58:05
你牛
by jomy @ 2023-03-16 21:58:49
额
by jomy @ 2023-03-16 22:02:33