/* Venue Scheduling issues
Time limit: Ms | Memory Limit: 65535 KB
Difficulty: 4
Describe the school's small auditorium every day there are many activities, there is time for these activities planned time conflict,
Some activities need to be selected for hosting. Xiao Liu's job is to arrange the school small auditorium activities,
Schedule up to one activity at a time. Now Xiao Liu has some schedule of activities, and he wants to arrange as many activities as possible.
May I ask how he should arrange it.
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.
The following n rows have two positive integers per line Bi,ei (0<=bi,ei<10000),
Indicates 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 10
10 11
3
1 10
10 11
11 20
Sample Output 1
2*/
<span style= "FONT-SIZE:18PX;" > #include <stdio.h> #include <algorithm> const int max=10001; using namespace Std; Use the sort function to get the header file struct time { int start; int end; }; struct bool Order_by_end (struct time a,struct time B) { if (a.end!=b.end) return a.end<b.end; else return a.start<b.start; } The definition of the sort function. int main () { int i,x,m,end,count; struct time A[max]; scanf ("%d", &x); while (x--) { count=1; scanf ("%d", &m); for (i=0;i<m;i++) scanf ("%d%d", &a[i].start,&a[i].end); Sort (a,a+m,order_by_end); End=a[0].end; for (i=1;i<m;i++) if (a[i].start>end) { end=a[i].end; count++; } printf ("%d\n", count); } } </span>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Nyoj Venue Arrangement Issues