作者:
4_3
,
2022-01-10 23:03:41
,
所有人可见
,
阅读 14
#include <iostream>
#include <cstring>
#include <algorithm>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
PII pa[N];
int pe[N], ps[N];
int n, ans;
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i ++)
{
int a, b;
scanf("%d%d", &a, &b);
pa[i] = {a, b};
}
sort(pa, pa + n);
ps[0] = pa[0].y;
for (int i = 1; i < n; i ++)
ps[i] = max(ps[i - 1], pa[i].y);
pe[n - 1] = pa[n - 1].y;
for (int i = n - 2; i >= 0; i --)
pe[i] = min(pe[i + 1], pa[i].y);
for (int i = 0; i < n; i ++)
if (ps[i] == pe[i])
ans ++;
printf("%d", ans);
return 0;
}