样例能过,编了两个也能过,0分
查看原帖
样例能过,编了两个也能过,0分
767779
BD_AZZR_CN楼主2024/8/3 12:32
#include <iostream>
#include <queue>
using namespace std;
unsigned long long num[100000+1];
class info{
    public:
    unsigned long long Ph,Bi;
    info(){Bi=Ph=0;};
    //Ph && Bi
    info(const unsigned long long& O1,const unsigned long long& O2){Ph=O1;Bi=O2;};
};
class sort_by_Ph{
    public:
    bool operator()(const info& L, const info& R){
        return L.Ph<=R.Ph;
    };
};
priority_queue<info,vector<info>,sort_by_Ph> Phy;
class sort_by_Bi{
    public:
    bool operator()(const info&L, const info& R){
        return L.Bi<= R.Bi;
    };
};
priority_queue<info,vector<info>,sort_by_Bi> Bio;

int main(){
    unsigned long long n,a,b,B,P;
    unsigned long long ans=0;
    cin >> n >> a >> b;
    //物理成绩
    //生物成绩
    for(unsigned long long i = 1; i <= n; i++){
        cin >> num[i];//Phy
    }
    for(unsigned long long i = 1; i <= n; i++){
        P=num[i];
        cin >> B;
        if (b == 0) {
            Phy.push(info(P, B));
            continue;
        }
        if (a == 0) {
            Bio.push(info(P, B));
            continue;
        }
        if(B >= P){
            if(Bio.size() == b){//爆满
                if(B >= Bio.top().Bi){//有能力
                    Phy.push(Bio.top());//扔过去
                    Bio.pop();
                    Bio.push(info(P,B));//加入
                }
                else{//没能力
                    Phy.push(info(P,B));//加入对面
                }
            }
            else{
                Bio.push(info(P,B));//加入
            }
        }
        else{
            if(Phy.size() == a){//爆满
                if(P >= Phy.top().Ph){//有能力
                    Bio.push(Phy.top());
                    Phy.pop();
                    Phy.push(info(P,B));
                }
                else{//没能力
                    Bio.push(info(P,B));
                }
            }
            else{
                Phy.push(info(P,B));
            }
        }
    }
    // cout<<"END";
    // exit(0);
    while(!Bio.empty()){
        ans += Bio.top().Bi;
        Bio.pop();
    }
    while(!Phy.empty()){
        ans += Phy.top().Ph;
        Phy.pop();
    }
    cout << ans;
}
2024/8/3 12:32
加载中...