lzP1803
查看原帖
lzP1803
1191341
smart_lizan楼主2024/2/27 15:46

题解在此

#include <bits/stdc++.h>
const int N=1e6+5;
using namespace std;
typedef long long ll;
pair<ll,ll>a[N];
int main()
{
    ll n,ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i].second>>a[i].first;
    }
    sort(a+1,a+n+1);
    ll next=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i].second>=next)
        {
            next=a[i].first;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}
2024/2/27 15:46
加载中...