这个题为什么有的WA有的RE啊求助dalao
查看原帖
这个题为什么有的WA有的RE啊求助dalao
601747
xibaohe楼主2023/1/5 18:38

dalao们

求助 题解区看不懂

#include<bits/stdc++.h>
using namespace std;

int n,a[100005],q;

int main(){
    scanf("%d %d",&n,&q);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    while(q--)
    {
    	int t;
    	scanf("%d",&t);
    	if(binary_search(a+1,a+n+1,t)==true)
    	cout<<lower_bound(a+1,a+n+1,t)-a<<" ";
    	else
    	cout<<-1<<" ";
	}
    return 0;
}



2023/1/5 18:38
加载中...