HDU-2037 今年暑假不AC

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 #define pb push_back
 5 #define maxSize 3939
 6 #define _for(i,a,b) for(int i = (a);i < (b);i ++)
 7 
 8 struct s
 9 {
10     int op;
11     int ed;
12 };
13 
14 bool cmp(s s1,s s2)
15 {
16     return s1.ed < s2.ed;
17 }
18 
19 int main()
20 {
21     vector<s> list;
22     int num;
23     while(~scanf("%d",&num) && num!=0)
24     {
25         _for(i,0,num)
26         {
27             int a,b;
28             scanf("%d %d",&a,&b);
29             list.push_back(s{a,b});
30         }
31         
32         sort(list.begin(),list.end(),cmp);
33         
34         int cnt = 0;
35         cnt ++;
36         int overtime = list[0].ed;
37         _for(i,1,num)
38         {
39             if(list[i].op >= overtime)
40             {
41                 cnt ++;
42                 overtime = list[i].ed;
43             }
44         }
45         cout << cnt << endl;
46         list.clear();
47     }
48     
49     return 0;
50 }

 

posted @ 2019-03-20 15:37  Asurudo  阅读(172)  评论(0编辑  收藏  举报