Furukawa_Nagisa @ 2024-04-14 22:49:55
求调 悬关 拜托了啊啊啊
代码,自测样例过了:
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1000003],r,l,mid;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
while(m--){
int s;cin>>s;
r=n,l=0;
int flag=0;
while(l<r){
mid=l+(r-l)/2;
if(a[mid]>s) r=mid;
else if(a[mid]<s) l=mid+1;
else{
while(a[mid-1]==a[mid]) mid--;
cout<<mid<<" ";
flag=1;
break;
}
}
if(flag==0)cout<<-1;
}
return 0;
}
by ivnilkkk @ 2024-04-17 19:54:08
@LzxQwQ 你艾特错人了。
by LzxQwQ @ 2024-04-17 19:56:03
@DAhhr76 sorry QwQ
by ivnilkkk @ 2024-04-17 19:57:22
@LzxQwQ 没事啦 qwq。