poj 2559
来源:互联网 发布:淘宝设置收藏送优惠券 编辑:程序博客网 时间:2024/05/17 08:45
#include <iostream>#include <cstdio>using namespace std;const int N = 100005;struct Elem{int height;int count;};Elem stack[N];int top;int main(){int height, n;long long ans, tot, tmp;while (scanf("%d", &n) != EOF && n){top = 0;ans = 0;for (int i = 0; i < n; ++i){scanf("%d", &height);tmp = 0;while (top > 0 && stack[top - 1].height >= height){tot = stack[top - 1].height * (stack[top - 1].count + tmp);if (tot > ans) ans = tot;tmp += stack[top - 1].count;--top;}stack[top].height = height;stack[top].count = 1 + tmp;++top;}int tmp = 0;while (top > 0){tot = stack[top - 1].height * (stack[top - 1].count + tmp);if (tot > ans) ans = tot;tmp += stack[top - 1].count;--top;}printf("%lld\n", ans);}return 0;}
0 0
- POJ 2559
- poj 2559
- poj 2559
- poj -2559
- poj 2559
- 【POJ】2559
- POJ 2559 最大矩形面积 poj 3494
- POJ-2559(单增栈)
- POJ 2559 单调栈
- POJ 2559 单调栈
- POJ 2559 最大矩形。。
- poj 2559(单调栈)
- poj 2559 单调栈
- POJ 2559 dp 【复习】
- POJ 2559 单调栈
- POJ 2559 水题
- poj 2559 单调栈
- 栈(poj 2559)
- MySQL中函数CONCAT及GROUP_CONCAT
- Linux下find命令使用
- 学习笔记—进程间通信
- 【C++】了解C++11新特性
- iOS-URLconnection
- poj 2559
- KMP算法总结
- 依赖注入?Dagger?
- LeetCode:Longest Valid Parentheses
- HBase体系架构
- listView优化
- 顺序表应用4:元素位置互换之逆置算法
- 使用Java API 操作Hbase表出现异常:Exception in thread "main" java.lang.NoClassDefFoundError
- JNI 错误: 无法访问android.app.Activity