0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 07:51:58 +00:00

P3871 [TJOI2010]中位数

R42008699
This commit is contained in:
Baoshuo Ren 2020-11-16 18:42:08 +08:00 committed by Baoshuo Ren
parent e93f7eacc9
commit 86a61ddaf6
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
problem/P3871/P3871.cpp Normal file
View File

@ -0,0 +1,26 @@
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,m, t;
string op;
vector<int> nums;
cin >> n;
for(int i = 0 ; i < n ; i++) {
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
}
cin >> m;
for(int i = 0 ; i < m ; i++) {
cin >> op;
if(op == "add") {
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
}
else {
cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl;
}
}
return 0;
}