Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 27733 Accepted Submission(s): 14664
ios
1 #include <iostream> 2 #include<algorithm> 3 using namespace std; 4 #define N 105 5 struct Time{ 6 int Ti_s; 7 int Ti_e; 8 }Ti[N]; 9 bool cmp(Time a,Time b) 10 { 11 if(a.Ti_e != b.Ti_e) 12 return a.Ti_e<b.Ti_e; 13 return a.Ti_s<b.Ti_s; 14 } 15 16 int main() 17 { 18 int i, n, endtime, sum; 19 while(cin>>n && n) 20 { 21 for(i=0; i<n; i++) 22 cin>>Ti[i].Ti_s>>Ti[i].Ti_e; 23 sort(Ti,Ti+n,cmp); 24 sum = 1; 25 endtime = Ti[0].Ti_e; 26 for(i=1; i<n; i++) 27 { 28 if(endtime<=Ti[i].Ti_s) 29 { 30 sum++; 31 endtime = Ti[i].Ti_e; 32 } 33 } 34 cout<<sum<<endl; 35 } 36 return 0; 37 }