题解 100% AC
2025-08-25 14:45:08
发布于:江苏
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],m;
int main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
cin>>m;
while(m--){
int x;
cin>>x;
if(a[lower_bound(a+1,a+n+1,x)-a]!=x)cout<<-1<<" ";
else cout<<lower_bound(a+1,a+n+1,x)-a<<" ";
if(a[upper_bound(a+1,a+n+1,x)-a-1]!=x)cout<<-1<<" ";
else cout<<upper_bound(a+1,a+n+1,x)-a-1<<" ";
if(a[upper_bound(a+1,a+n+1,x)-a]==0)cout<<-1<<endl;
else cout<<upper_bound(a+1,a+n+1,x)-a<<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个