bnuoj 25659 A Famous City (单调栈)
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 (单调栈)的更多相关文章
- HDOJ 4252 A Famous City 单调栈
单调栈: 维护一个单调栈 A Famous City Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- HDU-4252 A Famous City(单调栈)
最后更新于2019.1.23 A Famous City ?戳这里可以前往原题 Problem Description After Mr. B arrived in Warsaw, he was sh ...
- 【BZOJ】1628 && 1683: [Usaco2007 Demo]City skyline 城市地平线(单调栈)
http://www.lydsy.com/JudgeOnline/problem.php?id=1628 http://www.lydsy.com/JudgeOnline/problem.php?id ...
- BZOJ 1628 [Usaco2007 Demo]City skyline:单调栈
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1628 题意: 题解: 单调栈. 单调性: 栈内元素高度递增. 一旦出现比栈顶小的元素,则表 ...
- 单调栈3_水到极致的题 HDOJ4252
A Famous City 题目大意 给出正视图 每一列为楼的高度 最少有几座楼 坑点 楼高度可以为0 代表没有楼 贡献了两发RE 原因 if(!s.empty()&&tem){s. ...
- Gym 100971D Laying Cables 单调栈
Description One-dimensional country has n cities, the i-th of which is located at the point xi and h ...
- BZOJ_1628_[Usaco2007_Demo]_City_skyline_(单调栈)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1628 给出\(n\)个距形的影子,问最少是多少个建筑的?(建筑的影子可以重叠). 分析 用单调 ...
- Code Forces Gym 100971D Laying Cables(单调栈)
D - Laying Cables Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- 小结:单调栈 & 单调队列
概要: 对于维护信息具有单调性的性质或者问题可以转化为具有单调性质的模型的题,我们可以考虑用单调栈或单调队列. 技巧及注意: 技巧很多,只要能将问题转化为单调性问题,就好解决了. 当维护固定长度的单调 ...
随机推荐
- 根据ie浏览器不同的类别选择不同的css
如果是IE浏览器则选择all-ie-only.css <!--[if IE]> <link rel="stylesheet" type="text/cs ...
- 八、android jni 之C语言基础
*含义 1.乘法 3*5 2.定义指针变量 int * p://定义了一个名字叫p的变量,能够存放int数据类型的地址 3.指针运算符, //如果p是一个已经定义好的指针变量则*p表示以p的内容为地址 ...
- Jsp万能密码漏洞修复例子
更多详细内容请查看:http://www.111cn.net/jsp/Java/58610.htm 如果网站出现这种“万能密码”漏洞该怎么办呢 'or'='or' 漏洞修复 方法有很多在这里介绍两种, ...
- php中simplexml_load_string使用实例
先用一段代码重现一下问题 乍一看,结果很让人费解: 代码如下 复制代码 <?php $string = <<<EOF <data> <foo><b ...
- java使用BufferedImage和Graphics实现图片合成
package com.igoxin.weixin.custom; import java.awt.Graphics; import java.awt.image.BufferedImage; imp ...
- web HTML5 调用摄像头的代码
最近公司要求做一个在线拍照的功能,具体代码如下: <html> <head> <title>html5调用摄像头拍照</title> <style ...
- 8款超酷体验的jQuery/CSS3应用插件
1.jQuery/CSS3实现Android Dock菜单效果 这是一款基于jQuery和CSS3的Android Dock菜单效果,点击底部的按钮即可让应用图标浮动上来,并且按钮也出现3D的翻转效果 ...
- The breakpoint will not currently be hit. No symbols have been loaded for this document."
C# exe calls function from a native C++ DLL, and breakpoints set inside C++ source code cannot be hi ...
- 在 linux x86-64 模式下分析内存映射流程
前言 在上一篇中我们分析了 linux 在 x86-32 模式下的虚拟内存映射流程,本章主要继续分析 linux 在 x86-64 模式下的虚拟内存映射流程. 讨论的平台是 x86-64, 也可以称为 ...
- centos5.4下mysql主从复制
centos5.4下mysql主从复制配置分享. 本文转自:http://www.jbxue.com/article/771.html 安装环境:centos 5.4 mysql版本:mysql 5. ...