fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ms(s,n) memset(s,n,sizeof(s))
  5. #define all(a) a.begin(),a.end()
  6. #define present(t, x) (t.find(x) != t.end())
  7. #define sz(a) int((a).size())
  8. #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  9. #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
  10. #define pb push_back
  11. #define pf push_front
  12. #define fi first
  13. #define se second
  14. #define mp make_pair
  15.  
  16. typedef long long ll;
  17. typedef unsigned long long ull;
  18. typedef long double ld;
  19. typedef pair<int,int> pi;
  20. typedef vector<int> vi;
  21. typedef vector<pi> vii;
  22.  
  23. const int MOD = (int) 1e9+7;
  24. const int INF = (int) 1e9+1;
  25. inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
  26. inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  27.  
  28. bool cmp(pi a, pi b){
  29. return a.se<b.se;
  30. }
  31.  
  32. int main(){
  33. int n;cin>>n;
  34. vii v(n);
  35. FOR(i,0,n){
  36. cin>>v[i].fi>>v[i].se;
  37. }
  38. sort(all(v),cmp);
  39. int ans =1;
  40. int tmp=v[0].se;
  41. FOR(i,1,n){
  42. if(v[i].fi>tmp){
  43. ans++;
  44. tmp=v[i].se;
  45. }
  46. }
  47. cout<<ans<<endl;
  48. }
  49.  
Success #stdin #stdout 0.01s 5696KB
stdin
Standard input is empty
stdout
1