洛谷P1803

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
struct race
{
    int first;
    int second;
};
bool cmp(race a,race b)
{
    return a.second < b.second;
}
int main()
{
    struct race a[100009];
    int i,n,c=1,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].first,&a[i].second);
    }
    sort(a,a+n,cmp);
    for(i=1,j=0;i<n;i++)
    {
        if(a[i].first>=a[j].second){
            c++;
            j=i;
        }
    }
    printf("%d",c);
    return 0;
}
原文地址:https://www.cnblogs.com/EchoZQN/p/9983687.html