0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-18 13:31:59 +00:00
OI-codes/Luogu/P3871/P3871.cpp

26 lines
563 B
C++
Raw Normal View History

2021-11-19 09:01:13 +00:00
#include <bits/stdc++.h>
2020-11-16 10:42:08 +00:00
using namespace std;
int main() {
2021-11-19 09:01:13 +00:00
int n, m, t;
2020-11-16 10:42:08 +00:00
string op;
vector<int> nums;
cin >> n;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
2020-11-16 10:42:08 +00:00
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
}
cin >> m;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < m; i++) {
2020-11-16 10:42:08 +00:00
cin >> op;
2021-11-19 09:01:13 +00:00
if (op == "add") {
2020-11-16 10:42:08 +00:00
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
2021-11-19 09:01:13 +00:00
} else {
2020-11-16 10:42:08 +00:00
cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl;
}
}
return 0;
}