原题地址
我谔谔,在看题目的时候突然发现:
这tm好像就是这一题
于是就AC了
经典的贪心线段覆盖题目
:
# include <bits/stdc++.h>
using namespace std;
int n;
struct node
{
int s,t;
}a[1010];
bool cmp(struct node x,struct node b)
{
return x.t<=b.t;
}
int main(void)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a[i].s,&a[i].t);
}
sort(a+1,a+n+1,cmp);
int tot=0,lst=1;
for(int i=1;i<=n;i++)
{
if(lst<=a[i].s)
{
tot++;
lst=a[i].t;
}
}
cout << tot << endl;
return 0;
}