#include <stdio.h>
#include <stdlib.h>
#define N 100
typedef struct{
int s;
int t;
}act;
act buf[N];
int cmp(void const *_x, void const *_y){
act *x = (act*)_x;
act *y = (act*)_y;
return x->t - y->t;
}
int actSchedule(act *arr, int n){
int i, tmp, c = 1;
qsort(arr, n, sizeof(act), cmp);
tmp = arr[0].t;
for(i = 1; i < n; ++i){
if(arr[i].s >= tmp){
++c;
tmp = arr[i].t;
}
}
return c;
}
int main(void){
int n, i;
while(scanf("%d", &n)!=EOF && n){
for(i = 0; i < n; ++i) scanf("%d%d", &buf[i].s, &buf[i].t);
printf("%d\n", actSchedule(buf, n));
}
return 0;
}
hdu2037 贪心 活动安排
最新推荐文章于 2022-12-11 09:08:52 发布