You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
866 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
#define l second
#define r first
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int n;
PII a[N];
/*
pairfirstpairfirstsecond
/x,ylsecond,rfirst
*/
int res, ed = -INF;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
a[i] = {y, x};
}
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (a[i].l > ed) {
res++;
ed = a[i].r;
}
}
cout << res << endl;
return 0;
}