Acwing 830. 单调栈

Acwing 830. 单调栈

题目描述

代码展示

cpp 复制代码
#include <iostream>

using namespace std;

const int N = 100010;

int stk[N], tt;

int main()
{
    int n;
    cin >> n;
    while (n -- )
    {
        int x;
        scanf("%d", &x);
        while (tt && stk[tt] >= x) tt -- ;
        if (!tt) printf("-1 ");
        else printf("%d ", stk[tt]);
        stk[ ++ tt] = x;
    }

    return 0;
}
相关推荐
码客-ygluu21 小时前
X3 LUA 异步分布式微服务集群框架
c++·架构·lua
forest_091 天前
多 Agent 协作第二课:交叉验证≠独立验证
人工智能·python·算法·机器学习·prompt·agi
九英里路1 天前
protobuf快速上手
网络·c++·中间件·json·谷歌·序列化·protobuf
纪念 2291 天前
C++ 算法基础 (差分)
开发语言·c++·算法
jyOverQ1 天前
从零学 JVM(六):垃圾回收算法详解——标记清除、标记复制与标记整理
jvm·算法
ShineWinsu1 天前
对于Qt:QTreeWidget常见属性以及QTreeWidgetItem类的解析
开发语言·c++·qt·gui·客户端·多叉树·qtreewidget
严肃小白兔1 天前
第 06/24 期:神经网络的反向传播算法:从链式法则到梯度计算
人工智能·神经网络·算法
落羽的落羽1 天前
【C++】C++17的主要特性
linux·服务器·开发语言·c++·算法·机器学习
【心态好不摆烂】1 天前
数据结构基础精讲3
数据结构·算法