技术栈

Acwing 830. 单调栈

BH042509092023-09-17 13:53

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;
}
上一篇:C语言 —— 初步入门知识(内存、指针、结构体)
下一篇:docker 存储挂载比较
相关推荐
tod113
10 小时前
C++ 核心知识点全解析(七)
开发语言·c++·面试经验
blackicexs
10 小时前
第六周第日天
数据结构·算法
逆境不可逃
10 小时前
LeetCode 热题 100 之 48.旋转图像
算法·leetcode·职场和发展
心愿许得无限大
10 小时前
模板与泛型
c++
Frostnova丶
10 小时前
LeetCode 1022. 从根到叶的二进制数之和
算法·leetcode
不会敲代码1
10 小时前
别再背柯里化面试题了,看完这篇你自己也会写
javascript·算法·面试
snowfoootball
10 小时前
优先队列/堆 题目讲解
学习·算法
SamtecChina2023
10 小时前
Samtec连接器设计研究 | 载流量:温升为什么重要?
大数据·网络·人工智能·算法·计算机外设
怎么没有名字注册了啊
10 小时前
解决Undefined symbol: _curl_easy_cleanup
c++·curl
程序员南飞
10 小时前
排序算法举例
java·开发语言·数据结构·python·算法·排序算法
热门推荐
01GitHub 镜像站点02Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services03【OpenClaw 本地实战 Ep.3】突破瓶颈:强制修改 openclaw.json 解锁 32k 上下文记忆04AI Agent 平台横评:ZeroClaw vs OpenClaw vs Nanobot05Clawdbot部署教程:解决‘gateway token missing’授权问题的完整步骤06OpenClaw 使用和管理 MCP 完全指南07AI agent:介绍 ZeroClaw 安装,使用08OpenClaw 安装之(三)DeepSeek模型接入配置和详细配置参数09AI 规范驱动开发“三剑客”深度对比:Spec-Kit、Kiro 与 OpenSpec 实战指南10让 Trae IDE 智能体 “读懂”文档 Excel+PDF+DOCX :mcp-documents-reader 工具使用指南