HDU-2037

#include <cstdio>

#include <cstdlib>

#include <iostream>

#include <cstring>

#include <algorithm>

#include <cmath>

using namespace std;

struct Node

{

    int start;

    int stop;

}a[101];

bool cmp(const Node a,const Node b)

{

    if(a.stop!=b.stop)return a.stop<b.stop;

}

int main()

{

    int n;

    while(scanf("%d\n",&n),n!=0)

    {

        for(int i=0;i<n;i++)

            scanf("%d %d",&a[i].start,&a[i].stop);

        sort(a,a+n,cmp);

        int result = 1;

        int j=0;

        for(int i=0;i<n;i++)

        {

            if(a[i].start>=a[j].stop)

                {result++;j=i;}

        }

        printf("%d\n",result);

    }



}

 

你可能感兴趣的:(HDU)