Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
376 B
2
Indexable
Never
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >> n;

  pair<int, int> p[n];

  for(int i = 0; i < n; i++) {
    cin >> p[i].second >> p[i].first;
  }
  sort(p, p + n);
  int t = p[0].first;
  int res = 1;
  for(int i = 1; i < n; i++) {
    if(p[i].second >= t) {
      res++;
      t = p[i].first;
    }

  }
  cout << res << endl;
  return 0;
}
 
Leave a Comment