请求加强数据
查看原帖
请求加强数据
1416993
dalu楼主2024/12/29 09:07

rtrt,vector可以水过

code:

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector < int > v;

int main(){
    int n;
    cin >> n;
    while(n--){
        int op,x;
        cin >> op >> x;
        if(op == 1) v.insert(lower_bound(v.begin(),v.end(),x),x);
        if(op == 2) v.erase(lower_bound(v.begin(),v.end(),x));
        if(op == 3) cout << lower_bound(v.begin(),v.end(),x) - v.begin() + 1 << '\n';
        if(op == 4) cout << v[x - 1] << '\n';
        if(op == 5) cout << v[lower_bound(v.begin(),v.end(),x) - v.begin() - 1] << '\n';
        if(op == 6) cout << v[upper_bound(v.begin(),v.end(),x) - v.begin()] << '\n';
    }
    return 0;
}
2024/12/29 09:07
加载中...