0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 18:25:24 +00:00
OI-codes/Luogu/P3369/P3369.cpp

27 lines
755 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
int main() {
2021-11-19 09:01:13 +00:00
int n, x, opt;
vector<int> a;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> opt >> x;
if (opt == 1) {
a.insert(lower_bound(a.begin(), a.end(), x), x);
2021-11-19 09:01:13 +00:00
} else if (opt == 2) {
a.erase(lower_bound(a.begin(), a.end(), x));
2021-11-19 09:01:13 +00:00
} else if (opt == 3) {
cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl;
2021-11-19 09:01:13 +00:00
} else if (opt == 4) {
cout << a[x - 1] << endl;
2021-11-19 09:01:13 +00:00
} else if (opt == 5) {
cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl;
2021-11-19 09:01:13 +00:00
} else if (opt == 6) {
cout << *upper_bound(a.begin(), a.end(), x) << endl;
}
}
return 0;
}