博客
关于我
poj 3250 Bad Hair Day 栈的简单运用
阅读量:697 次
发布时间:2019-03-17

本文共 597 字,大约阅读时间需要 1 分钟。

#include 
#include
using namespace std;int main(){ stack
s; int n; while (cin >> n) { int a[100000]; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (!s.empty() && a[i] < s.top()) { s.pop(); num--; } sum += num; num++; s.push(a[i]); } while (!s.empty()) s.pop(); cout << sum << endl; }}

注:请注意上述代码已剥离除<div><pre>等HTML标签外的所有无关内容,仅保留原始代码核心逻辑。代码已经过轻微优化,调整部分注释和格式,使其更易读。上述代码功能与原文一致。

转载地址:http://btnez.baihongyu.com/

你可能感兴趣的文章
SQL--合计函数(Aggregate functions):avg,count,first,last,max,min,sum
查看>>
OSChina 周五乱弹 ——吹牛扯淡的耽误你们学习进步了
查看>>
SQL--mysql索引
查看>>
OSChina 周四乱弹 ——程序员为啥要买苹果手机啊?
查看>>
OSChina 周日乱弹 —— 2014 年各种奇葩评论集合
查看>>
OSChina 技术周刊第十期,每周技术抢先看!
查看>>
OSError: no library called “cairo-2“ was foundno library called “cairo“ was foundno library called
查看>>
OSError: [WinError 193] %1 不是有效的 Win32 应用程序。
查看>>
osgearth介绍
查看>>
OSGi与Maven、Eclipse PlugIn的区别
查看>>
Osgi环境配置
查看>>
OSG——选取和拖拽
查看>>
OSG中找到特定节点的方法(转)
查看>>
OSG学习:C#调用非托管C++方法——C++/CLI
查看>>
OSG学习:OSG组成(三)——组成模块(续):OSG核心库中的一些类和方法
查看>>
OSG学习:OSG组成(二)——渲染状态和纹理映射
查看>>
OSG学习:WIN10系统下OSG+VS2017编译及运行
查看>>
OSG学习:人机交互——普通键盘事件:着火的飞机
查看>>
OSG学习:几何体的操作(一)——交互事件、简化几何体
查看>>
OSG学习:几何体的操作(二)——交互事件、Delaunay三角网绘制
查看>>