pikabi @ 2019-11-13 14:00:28
by pikabi @ 2019-11-13 14:00:43
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;
int n;
priority_queue <int, vector<int>, greater<int> > sm;
priority_queue <int, vector<int> > la;
int main(){
scanf("%d",&n);
for(int i = 1; i <= n; i++){
int x;
scanf("%d",&x);
if(i == 1) {
printf("%d\n",x);
la.push(x);
}
else {
if(x > la.top() ) sm.push(x);
else la.push(x);
if(i & 1){
while(abs(la.size() - sm.size() ) > 1){
if(la.size() > sm.size() ){
sm.push(la.top() );
la.pop() ; }
else {
la.push(sm.top() );
sm.pop() ;
}
}
if(la.size() > sm.size() ) printf("%d\n",la.top() );
else printf("%d\n",sm.top() );
}
}
}
return 0;
}
by NANJOMIKO @ 2019-11-13 14:05:48
改成这样?
int use1=la.size(),use2=sm.size();
while(abs(use1- use2 ) > 1){
但是你这个tle了
我为了看清你那张图我还自己交了一遍
by NANJOMIKO @ 2019-11-13 14:07:04
你还我正确率emmmmmm
by pikabi @ 2019-11-13 14:16:29
@NANJOMIKO 对不起(੭ˊᵕˋ)੭*ଘ
by pikabi @ 2019-11-13 14:17:01
@NANJOMIKO 是您后面的u和v没修改吧,不然就死循环了啊QAQ
by pikabi @ 2019-11-13 14:17:21
@NANJOMIKO 好了我A了thank you
by NANJOMIKO @ 2019-11-13 14:20:11
@pikabi
啊啊啊我看漏了什么吗Σ(っ °Д °;)っ我只改了CE的地方
by 周世正 @ 2020-02-15 09:58:59