Venue Scheduling issues time limit: Ms | Memory limit: 65535 KB Difficulty: 4 Description The school's small auditorium has a lot of activities every day, there is time to plan the time of these activities conflict, you need to choose some activities to organize. Xiao Liu's job is to arrange the activities of the school chapel, with a maximum of one event per time. Now Xiao Liu has some schedule of activities, he would like to arrange as many activities as possible, ask him how to arrange.
The input first line is an integer number M (m<100) representing a total of M-Group test data.
The first line of each set of test data is an integer n (1<n<10000) that indicates that there are n activities in the test data.
Subsequent n rows, each line having two positive integers bi,ei (0<=bi,ei<10000), representing the start and end time of the first activity (BI<=EI)
Outputs the maximum number of activities that can be scheduled for each set of inputs.
Output of each group takes one line sample input
2
2
1,
3 1,
11 20
Sample output
1
2
<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" > #include <stdio.h> #include <stdlib.h> struct node {int s; Start time int t;
End time};
Node a[10001];
int cmp (const void *a,const void *b) {node *c = (node *) A;
Node *d = (node *) b;
if (c->t>d->t) {return 1;
} else {return-1;
}} int main () {int m,n,i,ans,tmp;
scanf ("%d", &m);
while (m--) {scanf ("%d", &n);
if (n==0) {printf ("0\n"); } else {for (i=0;i<n;i++) {scanf ("%d%d", &a[i].s,&a[i].
T);
} qsort (A,n,sizeof (a[0]), CMP);//end time from small to large sort tmp=0;
Ans=1;
for (i=1;i<n;i++) {if (a[i].s>a[tmp].t)//Take the second start time to start and the first end time to compare more than start plus, and place a note
{ans++;
Tmp=i;
}
} printf ("%d\n", ans);
}} return 0;
}</span>