Nyoj Venue Arrangement Issues

Source: Internet
Author: User



/* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.