POJ 2559 Largest Rectangle in a Histogram(单调栈)
来源:互联网 发布:数据库垂直切分 编辑:程序博客网 时间:2024/05/22 21:22
题目链接:POJ 2559 Largest Rectangle in a Histogram
#include <iostream>#include <cstdio>#include <stack>using namespace std;struct Node{ int l; long long h;};int main(){ int n; while(scanf("%d", &n), n) { long long h, k = 0, _max = 0; stack <Node> S; Node temp, tmp; for(int i = 0; i < n; i++) { scanf("%lld", &h); temp.l = i, temp.h = h; while(!S.empty() && S.top().h >= h) { tmp = S.top(); S.pop(); k = tmp.h * (i - tmp.l); temp.l = tmp.l; _max = max(_max, k); } S.push(temp); } while(!S.empty()) { tmp = S.top(); S.pop(); k = tmp.h * (n - tmp.l); _max = max(_max, k); } printf("%lld\n", _max); } return 0;}
0 0
- POJ 2559 -- Largest Rectangle in a Histogram ( 单调栈 )
- 【单调栈】POJ-2559 Largest Rectangle in a Histogram
- POJ 2559 Largest Rectangle in a Histogram(单调栈)
- POJ 2559 Largest Rectangle in a Histogram RMQ || 单调栈
- POJ 2559 Largest Rectangle in a Histogram(单调栈)
- POJ - 2559 Largest Rectangle in a Histogram 单调栈
- 【单调栈】POJ 2559 Largest Rectangle in a Histogram
- POJ 2559 Largest Rectangle in a Histogram(单调栈)
- POJ-2559-Largest Rectangle in a Histogram-单调栈
- 【POJ 2559】Largest Rectangle in a Histogram(单调栈)
- poj 2559 Largest Rectangle in a Histogram(单调栈)
- poj--2559 Largest Rectangle in a Histogram(单调栈)
- 单调栈1002 POJ 2559 Largest Rectangle in a Histogram
- POJ 2559 Largest Rectangle in a Histogram 单调栈
- [POJ 2559 Largest Rectangle in a Histogram] 单调栈
- POJ 2559 Largest Rectangle in a Histogram (单调栈)
- [poj 2559] Largest Rectangle in a Histogram:单调栈
- POJ 2559 - Largest Rectangle in a Histogram(单调栈)
- aorg.gjt.mm.mysql.Driver和com.mysql.jdbc.Driver
- 杭电--1870--愚人节的礼物
- &和&&的区别
- 安卓(android)建立项目时失败,出现Android Manifest.xml file missing几种解决方法?(总结中)
- XTU OJ 1160 Harry Potter
- POJ 2559 Largest Rectangle in a Histogram(单调栈)
- Android系统SD驱动浅析
- java 邮件发送实现相关文章
- actionscript3.0 函数重载问题
- IOS的GCD
- Leetcode习题:Pow(x, n)
- Quartus II 13.1正式版(Windows版和Linux版破解)
- 字符串分割--java中String.split()用法
- 哎呀,sql语句记不清楚了。。。