/*
The input data contains multiple test instances, and the first line of each test instance has only one integer n (n<=100),
Represents the total number of shows you like to watch, followed by n rows of data, each row containing two data ti_s,ti_e (1<=i<=n),
Indicates the start and end times of the I program, respectively, with a positive integer for each time to simplify the problem.
。 N=0 indicates that the input is finished and not processed.
*/
Find the maximum number of full programs
#include <stdio.h>typedefstructnode{intstart; intend;} time[ the];voidMain () {intN; while(SCANF ("%d", &n) = =1&& n<= -&& n>0) { inti,j,k; Time KK; for(i=0; i<n;i++) scanf ("%d%d",&kk[i].start,&kk[i].end); for(i=0; i<n;i++) for(j=i+1; j<n;j++) if(kk[i].end>kk[j].end) { inttemp=Kk[i].start; Kk[i].start=Kk[j].start; Kk[j].start=temp; Temp=Kk[i].end; Kk[i].end=Kk[j].end; Kk[j].end=temp; } ints=0; intCount=0; for(k=0; k<n;k++) { if(kk[k].start>=s) {count++; S=Kk[k].end; }} printf ("%d\n", Count); }}
Basic introduction to Greedy method