OJ-Problems-Source/HDOJ/2037_autoAC.cpp
2016-08-19 16:52:35 +08:00

37 lines
768 B
C++

#include<stdio.h>
int main()
{
int i,j,n;
int s[100],e[100];
while(scanf("%d\n",&n)!=EOF&&n)
{
for(i=0;i<n;i++)
scanf("%d%d",&s[i],&e[i]);
int k=0,l=0;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(e[i]>e[j])
{
l=s[i];
s[i]=s[j];
s[j]=l;
k=e[i];
e[i]=e[j];
e[j]=k;
}
}
int count=0,m=0;
for(i=0;i<n;i++)
{
if(s[i]>=m)
{
count++;
m=e[i];
}
}
printf("%d\n",count);
}
return 0;
}