code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;
int ans = 1, tpr = 0;
vector<pair<int,int>>v;
int l, r;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> l >> r;
v.push_back({l,r});
}
sort(v.begin(),v.end());
tpr = v[0].second;
for(int i = 1; i < v.size(); i++){
if(v[i].first > tpr) ans++;
if(v[i].second > tpr) tpr = v[i].second;
}
cout << ans;
return 0;
}
标签:acwing803,int,合并,long,second,tpr,ans,区间
From: https://www.cnblogs.com/index-12/p/17297160.html