其他分享
首页 > 其他分享> > luogu 3467 [POI2008]PLA-Postering 单调栈

luogu 3467 [POI2008]PLA-Postering 单调栈

作者:互联网

Code:

#include<bits/stdc++.h>
#define setIO(s) freopen(s".in","r",stdin) 
#define ll long long 
using namespace std; 
ll sta[300000],x,y; 
int main(){
    int n,tp=0;   scanf("%d%lld%lld",&n,&x,&y); 
    sta[++tp]=y;  
    int ans=n;  
    for(int i=1;i<=n-1;++i){
        scanf("%lld%lld",&x,&y); 
        while(y<sta[tp]&&tp>0) --tp;  
        if(tp && sta[tp]==y) --ans;  
        sta[++tp]=y; 
    }
    printf("%d",ans); 
    return 0; 
}

  

标签:3467,POI2008,Postering,ll,tp,int,long,ans,sta
来源: https://www.cnblogs.com/guangheli/p/10885137.html