mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:48:48 +00:00
P3369 【模板】普通平衡树
R41954295
This commit is contained in:
parent
b5a11d7086
commit
782ac0d882
31
problem/P3369/P3369.cpp
Normal file
31
problem/P3369/P3369.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user