POJ 2559 单调栈
来源:互联网 发布:2013淘宝男装店铺排行 编辑:程序博客网 时间:2024/04/30 02:22
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<cmath>#include<queue>#include<map>#include<set>using namespace std;#define mxn 102000#define inf 0x3f3f3f3f#define eps 1e-8#define LL long long #define ull unsigned long long#define MP make_pairstruct node {LL h;//节点高度int pos; // 开始位置node() {}node ( LL _h, int _pos ) {h = _h;pos = _pos;}}a[mxn];node stk[mxn];int main() {int n;while( scanf( "%d", &n ) && n ) {for( int i = 1; i <= n; ++i ) {scanf( "%lld", &a[i].h );}int tail = 0;stk[0] = node( 0, 0 ); //防止出现栈为空的情况LL ans = 0;for( int i = 1; i <= n + 1; ++i ) {LL height = 0;if( i != n + 1 ) //i等于n+1弹出栈里所有节点height = a[i].h;node t( 0, i );while( stk[tail].h > height ) {t = stk[tail--];LL area = ( i - t.pos ) * t.h;ans = max( ans, area );}if( i == n + 1 )break;stk[++tail] = node( a[i].h, t.pos );}printf( "%lld\n", ans );}return 0;}
0 0
- POJ 2559 单调栈
- POJ 2559 单调栈
- poj 2559(单调栈)
- poj 2559 单调栈
- POJ 2559 单调栈
- poj 2559 单调栈
- poj 2559 单调栈
- POJ 2559 单调栈 Histogram
- poj 2559(单调栈)
- 单调栈(poj -- 2559)
- POJ 2559 单调栈模板
- POJ 2559 单调栈模板题
- POJ - 2559(单调栈入门题)
- 【单调栈】POJ 3250
- poj 2796#单调栈
- POJ 2796 单调栈~
- poj 2796(单调栈)
- poj 2059 单调栈
- 数字图像处理—算术运算基本作用及模板(样板,窗口,滤波器)运算
- UVa10120 - Gift?!
- 篮桥杯,翻硬币 (贪心)
- 黑马程序员_多线程2
- 记一种TDD方式:红绿憋,红绿再憋
- POJ 2559 单调栈
- WPF设置Image控件的图片淡入淡出更换
- 副老大的待遇
- Remove Duplicates from Sorted Array - LeetCode
- OpenThreads
- [IOS]UITextField中设置placeholder字体颜色
- WinSock网络编程学习(二)计算校验和程序
- Construct Binary Tree from Inorder and Postorder Traversal
- 黑马程序员-学习笔记/网络编程一