fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct bi
  4. {
  5. long long s;
  6. long long e;
  7. };
  8. bi x[1000000];
  9. bool ss(bi u,bi v)
  10. {
  11. return u.e<v.e;
  12. }
  13. long long n;
  14. int main()
  15. {
  16. cin>>n;
  17. for(int i=1;i<=n;i++)
  18. {
  19. cin>>x[i].s>>x[i].e;
  20. }
  21. sort(x+1,x+n+1,ss);
  22. long long res=1,enl=x[1].e;
  23. for(int i=2;i<=n;i++)
  24. {
  25. if(x[i].e==enl)
  26. continue;
  27. if(x[i].s>enl)
  28. {
  29. res++;
  30. enl=x[i].e;
  31. }
  32. }
  33. cout<<res;
  34.  
  35. }
  36.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
1