区间贪心 今年暑假不AC
#include<bits/stdc++.h>
using namespace std;
struct T{
int b;
int e;
bool operator < (const T & a){
return e<a.e;
}
};
int main(){
int n;
while(cin>>n){
if(n==0){
break;
}
T a[n];
for(int i=0;i<n;i++){
cin>>a[i].b>>a[i].e;
}
sort(a,a+n);
int time=0;
int answer=0;
for(int i=0;i<n;i++){
if(a[i].b>=time){
time=a[i].e;
answer++;
}
}
cout<<answer<<endl;
}
return 0;
}
using namespace std;
struct T{
int b;
int e;
bool operator < (const T & a){
return e<a.e;
}
};
int main(){
int n;
while(cin>>n){
if(n==0){
break;
}
T a[n];
for(int i=0;i<n;i++){
cin>>a[i].b>>a[i].e;
}
sort(a,a+n);
int time=0;
int answer=0;
for(int i=0;i<n;i++){
if(a[i].b>=time){
time=a[i].e;
answer++;
}
}
cout<<answer<<endl;
}
return 0;
}