zoukankan      html  css  js  c++  java
  • 洛谷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;
    }
  • 相关阅读:
    Codeforces 798C
    Codeforces 798B
    Codeforces 798A
    HDU
    HDU
    HDU
    加速cin的技巧
    Codeforces Gym
    Codeforces Gym
    Solutions to an Equation LightOJ
  • 原文地址:https://www.cnblogs.com/EchoZQN/p/9983687.html
Copyright © 2011-2022 走看看