webCode/Luogu/P1803/P1803.cpp

24 lines
452 B
C++

#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e6+5;
int n,nowT,ans;
struct _time{
int start,end;
}t[MaxN];
int main(){
cin>>n;
for (int i=1; i<=n; i++) {
cin>>t[i].start>>t[i].end;
}
sort(t+1,t+n+1,[](_time a,_time b){return a.end<b.end;});
for (int i=1; i<=n; i++) {
if (t[i].start>=nowT) {
ans++;
nowT=t[i].end;
}
}
cout<<ans<<endl;
}