123456789101112131415161718192021222324252627282930313233 |
- #include<bits/stdc++.h>
- using namespace std;
- const int MAX=100005;
- struct node{
- int s;
- int e;
- }a[MAX];
- int n;
- bool cmp(node x,node y)
- {
- return x.e<y.e;
- }
- int main()
- {
- while(cin>>n,n)
- {
- for(int i=0;i<n;i++)
- scanf("%d %d",&a[i].s,&a[i].e);
- sort(a,a+n,cmp);
- int temp=a[0].e,counter=1;
- for(int i=1;i<n;i++)
- {
- if(a[i].s>=temp)
- {
- counter++;
- temp=a[i].e;
- }
- }
- printf("%d\n",counter);
- }
- }
|