简单题解
2026-07-26 13:49:42
发布于:浙江
18阅读
0回复
0点赞
较简单,适合仅想要AC的人,点个赞吧QwQ
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int a[100010]={0};
int main(){
int n;
memset(a,-1,sizeof(a));
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int m;
cin>>m;
while(m--){
int a1=-1,b1=-1,b2=-1;
int num;
cin>>num;
if(a[lower_bound(a+1,a+n+1,num)-a]==num){
a1=lower_bound(a+1,a+n+1,num)-a;
}
if(a[upper_bound(a+1,a+n+1,num)-a-1]==num){
b1=upper_bound(a+1,a+n+1,num)-a-1;
}
if(a[upper_bound(a+1,a+n+1,num)-a]>num){
b2=upper_bound(a+1,a+n+1,num)-a;
}
cout<<a1<<' '<<b1<<' '<<b2<<'\n';
}
return 0;
}
全部评论 3
顶顶顶
2026-07-26 来自 浙江
0滴滴答答
2026-07-26 来自 浙江
0顶顶顶
2026-07-26 来自 浙江
0







有帮助,赞一个