http://www.bnuoj.com/bnuoj/problem_show.php?pid=25659

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack> using namespace std; int main()
{
int n,cas=;
while(~scanf("%d",&n))
{
int i;
stack<int> stk;
stk.push(-);
int ans = ;
for(i=;i<n;i++)
{
int temp;
scanf("%d",&temp);
while(stk.top()>temp)
{
stk.pop();
}
if(stk.top()!=temp)
{
stk.push(temp);
if(temp!=) ans++;
}
}
while(!stk.empty()){stk.pop();}
printf("Case %d: %d\n",cas++,ans);
}
return ;
}

bnuoj 25659 A Famous City (单调栈)的更多相关文章

  1. HDOJ 4252 A Famous City 单调栈

    单调栈: 维护一个单调栈 A Famous City Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  2. HDU-4252 A Famous City(单调栈)

    最后更新于2019.1.23 A Famous City ?戳这里可以前往原题 Problem Description After Mr. B arrived in Warsaw, he was sh ...

  3. 【BZOJ】1628 && 1683: [Usaco2007 Demo]City skyline 城市地平线(单调栈)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1628 http://www.lydsy.com/JudgeOnline/problem.php?id ...

  4. BZOJ 1628 [Usaco2007 Demo]City skyline:单调栈

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1628 题意: 题解: 单调栈. 单调性: 栈内元素高度递增. 一旦出现比栈顶小的元素,则表 ...

  5. 单调栈3_水到极致的题 HDOJ4252

    A Famous City 题目大意 给出正视图  每一列为楼的高度 最少有几座楼 坑点 楼高度可以为0 代表没有楼 贡献了两发RE 原因 if(!s.empty()&&tem){s. ...

  6. Gym 100971D Laying Cables 单调栈

    Description One-dimensional country has n cities, the i-th of which is located at the point xi and h ...

  7. BZOJ_1628_[Usaco2007_Demo]_City_skyline_(单调栈)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1628 给出\(n\)个距形的影子,问最少是多少个建筑的?(建筑的影子可以重叠). 分析 用单调 ...

  8. Code Forces Gym 100971D Laying Cables(单调栈)

    D - Laying Cables Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

  9. 小结:单调栈 & 单调队列

    概要: 对于维护信息具有单调性的性质或者问题可以转化为具有单调性质的模型的题,我们可以考虑用单调栈或单调队列. 技巧及注意: 技巧很多,只要能将问题转化为单调性问题,就好解决了. 当维护固定长度的单调 ...

随机推荐

  1. asp.net mvc @RenderBody()的问题

    在使用.net mvc 母版页布局时如果是进行上中下三块布局的话,那么就会像下面的图那样: 在上面的div 和下面的div之间会出现4cm的间隔, 解决如下: 给包裹@RenderBody()的div ...

  2. Part 34 to 35 Talking about multiple class inheritance in C#

    Part 34 Problems of multiple class inheritance Part 35 Multiple class inheritance using interfaces

  3. 收集一些常用的php正则表达式

    1.    平时做网站经常要用正则表达式,下面是一些讲解和例子,仅供大家参考和修改使用: 2.    "^\d+$" //非负整数(正整数 + 0) 3.    "^[0 ...

  4. [老老实实学WCF] 第五篇 再探通信--ClientBase

    老老实实学WCF 第五篇 再探通信--ClientBase 在上一篇中,我们抛开了服务引用和元数据交换,在客户端中手动添加了元数据代码,并利用通道工厂ChannelFactory<>类创 ...

  5. Mac OS X中开启或关闭显示隐藏文件

    打开终端,输入:defaults write com.apple.finder AppleShowAllFiles -bool true 此命令显示隐藏文件defaults write com.app ...

  6. 通过js判断手机访问跳转到手机站

    第一种方法: <script> ){ //pc //window.location.href="电脑网址"; }else{ //shouji window.locati ...

  7. AMQ学习笔记 - 20. 使用Apache ActiveMQBrowser监控ActiveMQ

    概述 Apache ActiveMQBrowser可以用于查看AMQ中的消息.这里对其使用方法进行简单介绍. 使用介绍 1.下载并解压缩 下载地址:Apache ActiveMQBrowser,当前最 ...

  8. ABAP OO与ALV结合方式探索(2)

    接上篇 一开始设计的BO 类是为了实现功能而实现功能 从类的单一职责的角度而言 先把这个BO对象拆分   这里又有一个需要考虑的点:   如何传递内表数据到ALV 如果引入一个中间变量,数据就会被do ...

  9. unity 3消 游戏

    3消游戏跟着智能手机流行到现在已经有很长一段时间,unity实现的3消 https://github.com/textcube/match3action 截图如下: 在阅读源码的时候不难发现,Game ...

  10. 村田噪声抑制基础教程-第一章 需要EMI静噪滤波器的原因

    1-1. 简介 EMI静噪滤波器 (EMIFIL®) 是为电子设备提供电磁噪声抑制的电子元件,配合屏蔽罩和其他保护装置一起使用.这种滤波器仅从通过连线传导的电流中提取并移除引起电磁噪声的元件.第1章说 ...