mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 18:52:02 +00:00
P3871 [TJOI2010]中位数
R42008699
This commit is contained in:
parent
e93f7eacc9
commit
86a61ddaf6
26
problem/P3871/P3871.cpp
Normal file
26
problem/P3871/P3871.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user