2020-11-07 15:47:19 +00:00
|
|
|
#include<bits/stdc++.h>
|
2020-11-07 13:08:59 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main() {
|
2020-11-07 15:47:19 +00:00
|
|
|
int n, a[100005], k;
|
|
|
|
priority_queue<int, vector<int>, less<int> > s;
|
|
|
|
priority_queue<int, vector<int>, greater<int> > l;
|
2020-11-07 13:08:59 +00:00
|
|
|
cin >> n;
|
2020-11-07 15:47:19 +00:00
|
|
|
for(int i = 1 ; i <= n ; i++) {
|
|
|
|
cin >> a[i];
|
|
|
|
k = i/2+1;
|
|
|
|
if(!l.empty() && a[i] >= l.top()) {
|
|
|
|
s.push(a[i]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
l.push(a[i]);
|
|
|
|
}
|
|
|
|
while(l.size() < k) {
|
|
|
|
l.push(s.top());
|
|
|
|
s.pop();
|
|
|
|
}
|
|
|
|
while(s.size() < k) {
|
|
|
|
s.push(l.top());
|
|
|
|
l.pop();
|
|
|
|
}
|
|
|
|
if(i%2) {
|
|
|
|
cout << s.top() << endl;
|
2020-11-07 13:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|