以结束时间为key,只存储考试用时最短的一组数据,建立map数组
#include <bits/stdc++.h>
using namespace std;
int n;
map<int,int> Count;
int main(){
scanf("%d",&n);
for (int i = 0; i < n; ++i) {
int a,b;
scanf("%d%d",&a,&b);
if (Count.find(b)==Count.end())Count[b]=a;
else{
if (Count[b]<a)
Count[b]=a;
}
}
int ans=0,temp;
for (auto i = Count.begin(); i !=Count.end() ; ++i) {
if (!ans){
temp=i->first;
ans++;
} else{
if (i->second>=temp){
temp=i->first;
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}```