#include<bits/stdc++.h>
using namespace std;
struct node
{
int l,r;
};
bool cmp(node x,node y){
return x.r<y.r;
}
class Solution{
public:
int solve(vector < node > num)
{
sort(num.begin(),num.end(),cmp);
int ans=0,sum=0;
for(int i=0; i<num.size(); i++)
{
if(sum<=num[i].l)
{
sum=num[i].r;
ans++;
}
}
return ans;
}
};
int main()
{
Solution x;
int n,m;vector < node > num;
cin>>n;
for(int i=1; i<=n; i++)
{
int a,b;cin>>a>>b;
num.push_back((node){a,b});
}
cout<<x.solve(num);
return 0;
}
标签:node,10007,1.1,int,线段,num,cmp
From: https://www.cnblogs.com/dadidididi/p/16600042.html