This summer holiday is not ac--hdu2037

Source: Internet
Author: User

Not AC this summer holiday

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 35614 Accepted Submission (s): 18987


Problem Description "Not AC this summer?" ”
Yes ”
"Then what do you do?" ”
"Watch the World Cup, you idiot!" ”
"@#$%^&*% ..."

Indeed, the World Cup has come, the fans of the festival has come, it is estimated that many acmer will also throw away the computer, to the TV.
As fans, must want to see as much as possible complete game, of course, as a new era of good youth, you will certainly see some other programs, such as news broadcast (never forget about the state of affairs), very 6+7, Super girls, and Wang Xiao Ya's "Happy Dictionary" and so on, If you already know the schedule of all the TV shows you like to watch, will you make reasonable arrangements? (The goal is to be able to see as many full programs as possible)

Input data contains multiple test instances, and the first line of each test instance has only one integer n (n<=100), representing the total number of shows you like to see, followed by n rows of data, each row containing two data ti_s,ti_e (1<=i<=n), Represents the start and end times of the I program, respectively, in order to simplify the problem, each time is represented by a positive integer. N=0 indicates that the input is finished and not processed.

Output for each test instance, outputs the number of TV shows that can be fully seen, one row for each test instance output.

Sample Input121 33 40 73 815 1915 2010 158 186 125 104 142 90

Sample OUTPUT5 I was learning after greed back to do this problem, first think about the information, start time, end time, the introduction can calculate the time, we know, to write this problem, first of all to sort, but by what sort? 1, according to the start time if the first one at the end of the late, not only to see one? So it's inappropriate. 2. On time long if the longest beginning, the end of the late, ibid, not suitable 3. Press END time ONLY this!!! Greedy
1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 6 struct  as7 {8     intbegin;9     intend;Ten      One} aa[104]; A   -  BOOLcmp asX asy) -  { the      returnx.end<y.end;//End Time Sort -  } -  intMain () -  { +           intn,i; -            while(SCANF ("%d",&N), N) +           { A                at            -                for(i=0; i<n;i++) -scanf"%d%d",&aa[i].begin,&aa[i].end); -Sort (aa,aa+n,cmp); -                intcot=1, tim=aa[0].end;//in the first one, it must be chosen. -                 for(i=1; i<n;i++) in                { -                        if(aa[i].begin>=Tim) to                        { +tim=Aa[i].end; -cot++; the                     } *                } $printf"%d\n", cot);Panax Notoginseng            } - } the            

This summer holiday is not ac--hdu2037

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.