#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define rep(i,x,y) for(ll i=(x);i<=(y);i++)
#define repl(i,x,y) for(ll i=(x);i<(y);i++)
#define repd(i,x,y) for(ll i=(x);i>=(y);i--)
using namespace std;
const ll N=3e6+5;
ll n,cnt,top,stack[N];
inline ll read() {
ll x=0;char ch=getchar();bool f=0;
while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
return f?-x:x;
}
int main() {
n=read();
rep(i,1,n) {
ll x=read(),y=read();
while(y<=stack[top]) cnt+=(y==stack[top--]);
stack[++top]=y;
}
printf("%lld\n",n-cnt);
return 0;
}
BZOJ P1113 「POI2008」海报PLA【单调栈】
猜你喜欢
转载自blog.csdn.net/yanzhenhuai/article/details/82934408
今日推荐
周排行