#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,t,c,x;
set<int> s;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>t;
s.insert(t);
}
for(int i=1;i<=m;i++){
cin>>c>>x;
if(c==1){
if(s.find(x)!=s.end())
cout<<x<<endl;
else{
cout<<"NO"<<endl;
}
}
if(c==2){
set<int>::iterator iter = s.begin();
if(x<=iter){
cout<<"NO"<<endl;
}
else{
set<int>::iterator it = s.lower_bound(x);
cout<<(--it)<<endl;
}
}
if(c==3){
set<int>::iterator iter = s.end();
if(x>=(--iter)){
cout<<"NO"<<endl;
}
else{
set<int>::iterator it = s.upper_bound(x);
cout<<it<<endl;
}
}
}
return 0;
}
using namespace std;
int main(){
int n,m,t,c,x;
set<int> s;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>t;
s.insert(t);
}
for(int i=1;i<=m;i++){
cin>>c>>x;
if(c==1){
if(s.find(x)!=s.end())
cout<<x<<endl;
else{
cout<<"NO"<<endl;
}
}
if(c==2){
set<int>::iterator iter = s.begin();
if(x<=iter){
cout<<"NO"<<endl;
}
else{
set<int>::iterator it = s.lower_bound(x);
cout<<(--it)<<endl;
}
}
if(c==3){
set<int>::iterator iter = s.end();
if(x>=(--iter)){
cout<<"NO"<<endl;
}
else{
set<int>::iterator it = s.upper_bound(x);
cout<<it<<endl;
}
}
}
return 0;
}
0 回复
0 转发
0 喜欢
2 阅读



