#include <bits/stdc++.h>
using namespace std;
const int b772=250010;
long long k[b772],h[b772];
long long zhan[b772];
int main(){
int n,ans,top=0;
scanf("%d",&n);
ans=n;
for(int i=1; i<=n; i++){
scanf("%lld%lld",&k[i],&h[i]);
while(top&&h[zhan[top]]>h[i]){
top--;
if(h[zhan[top]]==h[i]){
ans--;
}
}
zhan[++top]=i;
}
cout<<ans<<endl;
return 0;
}
附上我的代码。