POJ-2559利用栈往前迭代
来源:互联网 发布:ubuntu命令行运行软件 编辑:程序博客网 时间:2024/06/04 01:02
Largest Rectangle in a Histogram
POJ - 2559#include<iostream>#include<cstdio>#include <algorithm>#include <cstring>#include <set>#include <stack>using namespace std;const int N=int(1e5)+9;int h[N];int n;int main(){ while(cin>>n&&n){ for(int i=1;i<=n;i++){ scanf("%d",&h[i]); } long long ans=0; stack<int> s;s.push(0);h[++n]=0; for(int i=0;i<=n;i++){ while(h[i]<h[s.top()]){ long long a=h[s.top()]; s.pop(); long long b=i-s.top()-1; if(a*b > ans) ans=a*b; } s.push(i); } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- POJ-2559利用栈往前迭代
- for循环,增强型for循环,迭代(从前往后,从后往前)
- poj 2728(迭代+prime)
- [迭代] poj 2748 Logs Stacking
- POJ 2248 迭代加深搜索
- 利用 IBM Rational Suite AnalystStudio 进行迭代需求管理
- 利用迭代OTSU方法分割植物病斑
- PHP 利用函数的静态变量 指定迭代次数
- POJ 3921 Destroying the bus stations 迭代加深搜索
- POJ 2286 The Rotation Game 搜索-IDA*+迭代加深
- poj 2286 The Rotation Game (迭代加深搜索)
- POJ 3134 - Power Calculus 迭代加深搜索(DFSID)
- POJ 1753 Flip Game (迭代加深dfs 版本)
- poj 2965 The Pilots Brothers' refrigerator (迭代加深dfs)
- poj 3134 Power Calculus(迭代加深dfs)
- poj 3134 Power Calculus(迭代加深dfs)
- POJ-3134-Power Calculus(迭代加深DFS)
- 迭代加深搜索——POJ 3134
- WOJ1192-Image Conversion
- 组合数学基本工具-- 排列与组合以及简单公式
- Sdk界面UI开发自动适配屏幕技巧
- HDU_1003 Max Sum
- UVA 10935
- POJ-2559利用栈往前迭代
- 习题 6.13 编一程序,将两个字符串连接起来,不要用strcat函数。
- C++namespace(命名空间)
- TensorFlow CNN 相关类与方法
- github不能访问、加载css、js解决办法
- phpcms v9网站搬家更换域名的方法
- PAT1020. Tree Traversals (25)
- Qt学习之路(19): 事件(event)
- SQL注入学习二