样例过但是0分 大佬有时间帮帮蒻暨吧
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int INF = 1e9;
void solve()
{
int n;cin>>n;
vector<int>q(n + 1);
for(int i = 1; i <= n; i ++)
cin>>q[i];
priority_queue<int>les;
priority_queue<int,vector<int>,greater<int>>gr;
auto weihu = [&les,&gr](){
while(les.size() != gr.size() + 1)
{
if(les.size() > gr.size() + 1)
{
gr.push(les.top());
les.pop();
}
else
{
les.push(gr.top());
gr.pop();
}
}
while(!les.empty() && les.top() < gr.top())
{
int t = gr.top();
gr.pop();
gr.push(les.top());
les.pop();
les.push(t);
}
};
gr.push(q[1]);
cout << q[1] << endl;
for(int i = 2; i <= n; i ++)
{
gr.push(q[i]);
if(i%2)
{
weihu();
cout << gr.top() << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int T = 1;
//cin>>T;
while(T --)
{
solve();
}
return 0;
}