History cf137C 读假题的危害猛女落泪 pair!
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<pair<int,int> > v(n);
for(int i=0;i<n;i++){
cin>>v[i].first>>v[i].second;
}
sort(v.begin(),v.end());
int res=0;
int start=v[0].first,end=v[0].second;
for(int i=1;i<n;i++){
if(v[i].first>start && v[i].second<end)res++;
else {
start=v[i].first;end=v[i].second;
}
}
cout<<res;
}
#include<bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main(){
int n, x, y, far = 0, ans = 0; cin >> n;
for(int i = 0; i < n; i++) {
cin >> x >> y;
mp[x] = y;
}
for(auto [st, ed] : mp){
if(far > ed) ans++;
far = max(far, ed);
}
cout << ans;
return 0;
}