rt,真不知道哪有问题,调一上午了,求调,或者给hack也行
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string op;
long long n,x;
priority_queue <ll> mx;
priority_queue<ll,vector<ll>,greater<ll> > mn;
void init() {//add²Ù×÷£¬Åжϵ±Ç°Á½¸ö¶ÑµÄ״̬ÕÒµ½¸Ã²åÈëµÄλÖÃ
cin>>x;
if(mx.size()==mn.size()) {
if(mx.empty()){
mx.push(x);
}
else if(x<=mx.top()) mx.push(x);
else mn.push(x);
return;
}
if(mx.size()>mn.size()) {
if(mn.empty()){
if(x<=mx.top()){
mn.push(mx.top());
mx.pop();
mx.push(x);
}
else mn.push(x);
}
else
if(x<=mx.top()) {
mn.push(mx.top());
mx.pop();
mx.push(x);
}
else mn.push(x);
} else {
if(mx.empty()){
if(x>mn.top()){
mx.push(mn.top());
mn.pop();
mn.push(x);
}
else mx.push(x);
}
if(x<=mx.top()) mx.push(x);
else {
mx.push(mn.top());
mn.pop();
mn.push(x);
}
}
}
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
while(n--) {
init();
}
cin>>n;
while(n--) {
cin>>op;
if(op=="add") {
init();
}
else if(op=="mid") {
ll k;
if(mn.empty()&&mx.empty()) {
cout<<"0.0"<<endl;
continue;
}
if(mx.size()==mn.size()) {
k = min(mx.top(),mn.top());
} else if(mx.size()>mn.size()) {
k = mx.top();
} else {
k = mn.top();
}
cout<<k<<endl;
}
}
return 0;
}