#include <iostream>
#include<iostream>
#include<algorithm>
using namespace std;
struct point
{int x,y;
bool operator <(const point &b)const
{return y<b.y||y==b.y&&x>b.x;}
}a[1005];
int main()
{int i,j,k,m,n,ans,temp;
while(cin>>k)
{
for(i=0;i<k;i++)
cin>>a[i].x>>a[i].y;
sort(a,a+k);
ans=0;temp=-1;j=0;
while(j<k)
{
if(a[j].x>temp)
{temp=a[j].y;ans++;}
j++;
}
cout<<ans<<endl;
}
}
贪心法 区间选点问题 南阳oj 找点
最新推荐文章于 2020-03-02 13:19:31 发布