0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:56:28 +00:00

#104. 普通平衡树

https://loj.ac/s/1025512
This commit is contained in:
Baoshuo Ren 2021-01-03 00:00:16 +08:00 committed by Baoshuo Ren
parent 01f503d8bf
commit df8953662e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
LibreOJ/104/104.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
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);
} else if (opt == 2) {
a.erase(lower_bound(a.begin(), a.end(), x));
} else if (opt == 3) {
cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl;
} else if (opt == 4) {
cout << a[x - 1] << endl;
} else if (opt == 5) {
cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl;
} else if (opt == 6) {
cout << *upper_bound(a.begin(), a.end(), x) << endl;
}
}
return 0;
}