先用A自小到大排序,然后遍历数组,若当前元素的B大于之前所有B的最大值显然不包括在内,否则被取消
//SGU 133 Border
//greedy
//by night_watcher
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define N 16001
int n;
struct node{
ll x,y;
}outpost[N];
bool cmp(const node a,const node b){
return a.x<b.x;
}
int main(){
int i,j;
cin>>n;
for(i=0;i<n;i++){
cin>>outpost[i].x>>outpost[i].y;
}
sort(outpost,outpost+n,cmp);
ll max=outpost[0].y;
int cnt=0;
for(i=1;i<n;i++){
if(outpost[i].y<max){
cnt++;
}
else max=outpost[i].y;
}
cout<<cnt<<endl;
return 0;
}