Venue arrangement problem (Greedy Algorithm)

Source: Internet
Author: User

Venue arrangement problem (Greedy Algorithm)
Venue Schedule Problem time limit: 3000 MS | memory limit: 65535 KB difficulty: 4

Description
There are many activities in the auditorium of the school every day. The scheduled time for these activities may conflict, and you need to select some activities to hold. Xiao Liu's job is to arrange activities in the school auditorium. at most one activity can be arranged at a time. Now Mr. Liu has some schedules for his activities. He wants to arrange as many activities as possible. How can he arrange them.
Input
The first row is an integer m (m <100), indicating a total of m groups of test data.
The first row of each group of test data is an integer n (1 Next n rows, each row has two positive integers Bi, Ei (0 <= Bi, Ei <10000), indicating the start time and end time of the I-th activity (Bi <= Ei)
Output
For each group of inputs, the maximum number of activities that can be arranged is output.
Output of each group occupies one row
Sample Input
221 1010 1131 1010 1111 20
Sample output
12
#include
     
      #include#include
      
       using namespace std;struct mad{int s;int e;}t[10002];bool cmp(struct mad c,struct mad d){ return c.e
       
        >n;while(n--){int i,count=1,m;cin>>m;for(i=0;i
        
         >t[i].s>>t[i].e;sort(t,t+m,cmp);int end=t[0].e;for(i=1;i
         
          

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.