#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct program{
int s;
int e;
bool operator < (const program &A)const {
return e < A.e;
}
}buf[110];
int main(){
int N;
while(scanf("%d",&N)!=EOF)
{
if(N == 0) break;
for(int i = 0; i < N; i++){
scanf("%d%d",&buf[i].s,&buf[i].e);
}
sort(buf,buf+N);
int ans = 0;
int i = 0;
int end = 0;
int start = 0;
while(i < N&&end<buf[N-1].e){
if(start <= buf[i].s){
end = buf[i].e;
start = end;
ans++;
}
i++;
}
cout<<ans<<endl;
}
return 0;
}
oj --贪心算法的运用,电视台节目
猜你喜欢
转载自blog.csdn.net/weixin_38023259/article/details/104107075
今日推荐
周排行