博客
关于我
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/

你可能感兴趣的文章
php openssl aes ecb,php openssl_encrypt AES-128-ECB iOS
查看>>
php paypal rest api,PayPal REST API指定网络配置文件PHP
查看>>
php pcntl 多进程学习
查看>>
PHP pcntl_fork不能在web服务器中使用的变通方法
查看>>
php private ,public protected三者的区别
查看>>
php PSR规范
查看>>
php rand() 重复,array_rand()函数从另外一个数组中随机取得的一定数量的数组的元素是否会重复?...
查看>>
php redis pub/sub(Publish/Subscribe,发布/订阅的信息系统)之基本使用
查看>>
php redis 集群扩展类文件
查看>>
php redis(2)
查看>>