样例过,交上去全WA

P1168 中位数

Wildchesse @ 2023-02-07 13:44:59

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,t;
priority_queue<int,vector<int>,greater<int> > qa;
priority_queue<int> qb;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>t;
        if(qa.size()==0 || t>=qa.top()) qa.push(t);
        else qb.push(t);
        if(i%2){
            if(qa.size()-qb.size()>1){
                qb.push(qa.top());
                qa.pop(); 
            }
            if(qb.size()>qa.size()){
                qa.push(qb.top());
                qb.pop(); 
            }
            cout<<qa.top()<<endl;
        } 

    }
    return 0;
}

by wdb0321 @ 2023-02-18 11:29:52

我也是,请官方加强一下数据


by appear_hope @ 2023-07-11 14:20:51

大哥你这是大根堆


|