-->
当前位置:首页 > 题库

PROGRAMMING:Maximum rectangle area of histogram

Luz5年前 (2021-05-10)题库397
A histogram is composed of many rectangles. It is required to find the largest rectangle area in a given histogram. It is assumed that the number of histogram rectangles does not exceed 1000.
Assume that all rectangles are one unit wide. As shown in the figure below, there are 7 rectangles in the histogram, with heights of 6, 2, 5, 4, 5, 1 and 6 respectively. Among them, the largest rectangle area composed of continuous rectangles is 12.
![ Histogram. JPG] (~ / 97160c8d-84d5-4c30-a9e9-46917c604e38. JPG)
Implementation tip: consider using stack to solve this problem.
###Input format:
The first line enters the number of rectangles in the histogram.
In the second line, enter the height of a set of histograms, with spaces between each height.
###Output format:
Output the maximum rectangle area that continuous rectangles can form.
###Input example:
Here is a set of inputs. For example:
```in
seven
6 2 5 4 5 1 6
```
###Output example:
The corresponding output is given here. For example:
```out
twelve
```







answer:If there is no answer, please comment