题目大意:原题链接 一排紧密相连的矩形,求能构成的最大矩形面积. 为了防止栈为空,所以提前加入元素(-1,0) #include<cstdio> #include<stack> #define maxn 100005 using namespace std; long long h[maxn]; struct Element { long long height; int startpos; Element(){} Element(long long _h,int _p){ hei…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19782   Accepted: 6393 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
传送门 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rec…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15831   Accepted: 5121 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
题目链接:http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24259   Accepted: 7844 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common bas…
                                                                                                   Largest Rectangle in a Histogram       A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 29498   Accepted: 9539 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
题意:求一个直方图中最大矩形的面积. 很经典的一道问题了吧,可以用单调栈分别求出每个柱子左右两边第一个比它低的柱子(也就相当于求出了和它相连的最后一个比它高的柱子),确定每个柱子的左右边界,每个柱子的高度乘上左右边界的宽度求最大值就行了. 也可以用笛卡尔树上dp的方法搞一搞,即用每个结点权值和所在子树的大小分别表示高度和宽度.(建笛卡尔树的过程也用到了单调栈,作用是维护右链) 单调栈做法: #include<bits/stdc++.h> using namespace std; typedef…
题目大意 有一个直方图,其所有矩形的底均是1(以后简称小矩形).给出这些矩形的高度,求这些矩形的并集中存在的面积最大的矩形(简称大矩形)的面积. 题解 大矩形的高必然一边等于一个小矩形的高,另一边小于等于另一个小矩形的高. 我们现考虑面积最大矩形左边高等于其所在小矩形的高的情况,则其右边高小于等于其对应的小矩形的高(以后将此简称为左等高矩形).我们要维护一个单调栈,使得栈里的矩形的高度都是单调递增的.一个一个枚举小矩形,如果当前小矩形高度比栈顶的矩形高度高或等,则如果所求大矩形是个左边为栈内矩形…
题目大意: 输入n,,1 ≤ n ≤ 100000,接下来n个数为每列的高度h ,0 ≤ hi ≤ 1000000000 求得最大矩阵的面积 Sample Input 7 2 1 4 5 1 3 34 1000 1000 1000 10000 Sample Output 84000   #include <bits/stdc++.h> #define ll long long using namespace std; ll n,a[],L[],R[],sta[]; // sta[]模拟栈 in…