题意:求序列上某区间最小值乘区间长度的最大值. 解题关键:很早就在<挑战程序设计竞赛>中见过了,单调栈模板题,注意弹栈时如何处理后面的元素. 法一:单调栈 #include<bits/stdc++.h> using namespace std; typedef long long ll; stack<int>s; ll a[]; int main(){ int n; cin>>n; ;i<n;i++) cin>>a[i];a[n]=-; l…
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 shows the histogram that consists of rectangles with the heights 2,…
题目:输入一个整数n,代表有n个 1(宽度) * h[i](高度)的矩形.接下来n个数依次给定一个矩形高度的高度h[i](i<=n). 求:在给定的依次排列的这堆矩形构成的图形里用一个矩形圈出最大的一个矩形,求该最大矩形面积. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; ll h[],s[],w[]; int n…