//区间贪心算法
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=110;
struct Interval{
int x,y;
}I[maxn];
bool cmp(Interval a,Interval b){
if(a.x!=b.x)return a.x>b.x;
else return a.y<b.y;
}
int main(){
int n;
while(scanf("%d",&n),n!=0){
for(int i=0;i<n;i++){
scanf("%d%d",&I[i].x,&I[i].y);
}
sort(I,I+n,cmp);
int ans=1,lastX=I[0].x;
for(int i=1;i<n;i++){
if(I[i].y<=lastX){
lastX=I[i].x;
ans++;
}
}
printf("%d")
}
return 0;
}
//区间贪心算法
最新推荐文章于 2025-03-29 16:10:30 发布
1万+

被折叠的 条评论
为什么被折叠?



