• Source
    1. #include <iostream>
    2. #include <algorithm>
    3. using namespace std;
    4.  
    5. struct gio
    6. {
    7. int s;
    8. int f;
    9. } typedef timeh;
    10.  
    11. int cmp (timeh a, timeh b)
    12. {
    13. if (a.f>b.f) return 0;
    14. return 1;
    15. }
    16.  
    17. int main ()
    18. {
    19. //IN;
    20. timeh h[10004];
    21. int n;
    22. cin>>n;
    23. for (int i=0; i<n; i++)
    24. {
    25. cin>>h[i].s>>h[i].f;
    26. }
    27. //OUT;
    28. sort (h, h+n, cmp);
    29. int count=0;
    30. int next=0;
    31. int x=h[0].s;
    32. for (int i=0; i<n; i++)
    33. {
    34. if (x<=h[i].s)
    35. {
    36. count++;
    37. x=h[i].f;
    38. }
    39. }
    40. cout<<count;
    41.  
    42. return 0;
    43. }