Not AC this summer holiday
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 32877 Accepted Submission (s): 17471
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 Code:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include < ctype.h> #include <iostream> #include <string> #include <algorithm>using namespace std;struct node { int st;//start time int et;//end time bool operator < (const node &X) const{ if (et==x.et) return st& Lt;x.st; else return et<x.et; }} Q[200];int Main () { int n; int I, J; while (scanf ("%d", &n) && n!=0) {for (i=0; i<n; i++) { scanf ("%d%d", &q[i].st, &q[i].et); } Sort (q, q+n); int Ans=1; int j=0; The first end of the program must be selected for (i=1; i<n; i++) { if (q[i].st >= q[j].et) { ans++; J=i; Update to the subscript of the currently-selected show } printf ("%dn", ans); } return 0;}
HDU 2037 this summer holiday does not AC (Start and end time "greedy")