比赛 2024暑假C班集训8 评测结果 AAAAAAAAAA
题目名称 吉他 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.101 s
代码语言 C++ 内存使用 2.87 MiB
提交时间 2024-07-08 09:55:50
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
const int N = 1e5+10;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int n,m,ans;
priority_queue<int,vector<int>,less<int> >q[10];
int main(){
    freopen("gitara.in","r",stdin);
    freopen("gitara.out","w",stdout);
    n = read(),m = read();
    for(int i = 1;i <= n;i++){
        int x = read(),y = read();
        while(!q[x].empty() && q[x].top() > y)q[x].pop(),ans++;
        if(q[x].empty() || q[x].top() != y)ans++,q[x].push(y);
    }
    printf("%d\n",ans);
    
    
    return 0;
    
}