Advertisement
Saleh127

CSES 1629

Apr 17th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. vector<pair<ll,ll>>x;
  11.  
  12. ll n,m=0,i,j,k,l=0;
  13.  
  14. cin>>n;
  15. for(i=0;i<n;i++)
  16. {
  17. cin>>j>>k;
  18. x.push_back({k,j});
  19. }
  20. sort(x.begin(),x.end());
  21.  
  22. for(auto s:x)
  23. {
  24. if(s.second>=l)
  25. {
  26. m++;
  27. l=s.first;
  28. }
  29. }
  30. cout<<m<<endl;
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement