比赛 2024暑假C班集训8 评测结果 AAAAAAAAAA
题目名称 吉他 最终得分 100
用户昵称 wdsjl 运行时间 0.375 s
代码语言 C++ 内存使用 2.87 MiB
提交时间 2024-07-08 11:39:15
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;

long long n,p,res;

priority_queue <long long>q_1;
priority_queue <long long>q_2;
priority_queue <long long>q_3;
priority_queue <long long>q_4;
priority_queue <long long>q_5;
priority_queue <long long>q_6;

int main(){
    freopen("gitara.in","r",stdin);
    freopen("gitara.out","w",stdout);
    scanf("%d%d",&n,&p);
    for(int i=1;i<=n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x==1){
           while(q_1.size()&&q_1.top()>y){
                q_1.pop();
                res++;
            }
            res++;
            if(q_1.size()&&q_1.top()==y){
            res--;
            }else{    
            q_1.push(y);
            }
        }else if(x==2){
            while(q_2.size()&&q_2.top()>y){
                q_2.pop();
                res++;
            }
            res++;
            if(q_2.size()&&q_2.top()==y){
            res--;
            }else{    
            q_2.push(y);
            }
        }else if(x==3){
            while(q_3.size()&&q_3.top()>y){
                q_3.pop();
                res++;
            }
            res++;
            if(q_3.size()&&q_3.top()==y){
            res--;
            }else{    
            q_3.push(y);
            }
        }else if(x==4){
            while(q_4.size()&&q_4.top()>y){
                q_4.pop();
                res++;
            }
            res++;
            if(q_4.size()&&q_4.top()==y){
            res--;
            }else{    
            q_4.push(y);
            }
        }else if(x==5){
            while(q_5.size()&&q_5.top()>y){
                q_5.pop();
                res++;
            }
            res++;
            if(q_5.size()&&q_5.top()==y){
            res--;
            }else{    
            q_5.push(y);
            }
        }else if(x==6){
            while(q_6.size()&&q_6.top()>y){
                q_6.pop();
                res++;
            }
            res++;
            if(q_6.size()&&q_6.top()==y){
            res--;
            }else{    
            q_6.push(y);
            }
        }
    }
    printf("%lld",res);
    return 0;
}