首页 > 其他 > 详细

luogu 3467 [POI2008]PLA-Postering 单调栈

时间:2019-05-18 12:30:44      阅读:120      评论:0      收藏:0      [点我收藏+]

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; 
}

  

luogu 3467 [POI2008]PLA-Postering 单调栈

原文:https://www.cnblogs.com/guangheli/p/10885137.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!