首页 > Windows开发 > 详细

单调栈.acwing.830

时间:2020-12-25 16:27:37      阅读:61      评论:0      收藏:0      [点我收藏+]

技术分享图片

code:

#include<bits/stdc++.h>
using namespace std;
int a[100010],top;
int main()
{
    int n;
    cin>>n;
    a[0]=-1;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        while(top&&a[top]>=x)top--;
        printf("%d ",a[top]);
        a[++top]=x;
    }
    return 0;
}

 

单调栈.acwing.830

原文:https://www.cnblogs.com/xfldbk/p/14189477.html

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