Problem Description
Input
Output
Example Input
12
15 20
15 19
8 18
10 15
4 14
6 12
5 10
2 9
3 8
0 7
3 4
1 3 
Example Output
5
 
 
 
 
 #include <stdio.h>
 #include <stdlib.h>
 struct node
 {
     int b;
     int e;
 }p[101],t;
 int main()
 {
     int n,i,j,k,h;
     while(~scanf("%d",&n))
     {
         for(i=0;i<n;i++)
             scanf("%d%d",&p[i].b,&p[i].e);
         for(i=0;i<n-1;i++)//冒泡排序;
             for(j=0;j<n-i-1;j++)
         {
             if(p[j].e>p[j+1].e)
             {
                 t=p[j];p[j]=p[j+1];
                 p[j+1]=t;
             }
         }
         k=1;h=p[0].e;
         for(j=1;j<n;j++)//是否选择活动
         {
             if(h<=p[j].b)
                {
                 k++;
                 h=p[j].e;
                }
         }
         printf("%d\n",k);
     }
     return 0;
 }