7 条题解

  • 0
    @ 2025-2-19 18:21:22

    #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(c1){ if(s.find(x)!=s.end()) cout<<x<<endl; else{ cout<<"NO"<<endl; } } if(c2){ 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; }

    信息

    ID
    70
    时间
    2000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    372
    已通过
    123
    上传者