本踢灵魂与活动选择相同,我只是因为测试时复制方便便在这里写了这篇博客
hhhh,
#include <bits/stdc++.h>
using namespace std;
struct node
{
int a;
int l,r;
}record[10010];
bool cmp(const node& a,const node& b)
{return a.r<b.r;}
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
{
cin>>record[i].l>>record[i].r;
record[i].a=i+1;
}
sort(record,record+n,cmp);
int count=0;
int lastend=-1;
for(i=0;i<n;i++)
{
if(record[i].l>=lastend)
{
count++;
lastend=record[i].r;
}
}
printf("%d\n",count);
}
return 0;
}