#include <bits/stdc++.h>
using namespace std;
#define ll long long
priority_queue<ll> bg;
priority_queue<ll, vector<ll>, greater<ll> > sm;
ll n, x;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> x;
cout << x;
sm.push(x);
for (int i = 2; i <= n; i++)
{
cin >> x;
if (x < sm.top()) bg.push(x);
else sm.push(x);
while (abs(sm.size() - bg.size()) > 1)
{
if (sm.size() < bg.size())
{
sm.push(bg.top());
bg.pop();
}
else
{
bg.push(sm.top());
sm.pop();
}
}
if (i & 1)
{
cout << endl;
if (bg.size() > sm.size()) cout << bg.top();
else cout << sm.top();
}
}
return 0;
}
在Dev上正常运行,编译命令:-Wall -O2 -std=c++14,没有警告没有报错,但在洛谷上就CE了,求助!