洛谷【算法1-5】贪心
凌乱的yyy//线段覆盖
#include <iostream>
#include<algorithm>
using namespace std;
struct cc
{
int ks,js;
} a[9999999];
bool cmp(cc a1,cc a2)
{
return a1.js<a2.js;
}
int n,i;
int sum=0,x;
int main()
{
cin>>n;
for(i=0; i<n; i++)
{
cin>>a[i].ks>>a[i].js;
}
sort(a,a+n,cmp);
for(i=0; i<n; i++)
{
if(a[i].ks>=x)
{
x=a[i].js;
sum++;
}
}
cout<<sum<<endl;
return 0;
}