abruce @ 2019-12-22 09:53:46
#include <bits/stdc++.h>
using namespace std;
int n;
priority_queue<int> q1;
priority_queue<int,vector<int>,greater<int> > q2;
int main() {
int x;
cin>>n;
for(register int i=1; i<=n; i++) {
cin>>x;
//cout<<"*";
if(!q2.size()||x>q1.top()) {
q2.push(x);
} else {
q1.push(x);
}
cout<<q1.size()<<' '<<q2.size()<<endl;
while((q2.size()-q1.size())>1) {
int u=q2.top();
q2.pop();
q1.push(u);
}
while((q1.size()-q2.size())>1) {
int u=q1.top();
q1.pop();
q2.push(u);
}
if(i%2==1) {
if(q1.size()>q2.size()) {
cout<<q1.size()<<endl;
} else {
cout<<q2.size()<<endl;
}
}
}
return 0;
}
by impuk @ 2019-12-22 14:16:12
因为您
AKIOI
a | k | i | o | i |
---|
by yucn7425 @ 2019-12-22 23:09:09
YQH:你太弱了!
by 周世正 @ 2020-02-15 20:59:53
A | K | I | O | I |
---|
by hahaha1215 @ 2022-03-02 21:00:20
队列的
只要改成while((int)(da.size()-xiao.size())>0)就好了!