POJ 2559 Largest Rectanglen a Higogram(単調スタック)
5736 ワード
【タイトルリンク】:click here~~
【タイトルの大意】:
A histogram is a polygon coposed of a sequence of rectangles aligned aa common base line.The rectangles have equal widths but may have different heights.Foxxample,the figure on the ft the shshshshshatototototoshshshshshshatotototoshshshshshshshshshshatotototototototoshshshshshshshshles s s shshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshleles、the shshattttttis the width of the rectangles:
Usually,histograms ared to represent discrete distributions,e.g.the frequencies of characters.Note the order of the rectangles,i.e.their height,is importer.Calcuthelatte of thelant lacture of the morrable.too.The figure on the right shows the larget aligned rectangle for the depicted histogram.
Sample Input
【タイトルの大意】:
A histogram is a polygon coposed of a sequence of rectangles aligned aa common base line.The rectangles have equal widths but may have different heights.Foxxample,the figure on the ft the shshshshshatototototoshshshshshshatotototoshshshshshshshshshshatotototototototoshshshshshshshshles s s shshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshshleles、the shshattttttis the width of the rectangles:
Usually,histograms ared to represent discrete distributions,e.g.the frequencies of characters.Note the order of the rectangles,i.e.their height,is importer.Calcuthelatte of thelant lacture of the morrable.too.The figure on the right shows the larget aligned rectangle for the depicted histogram.
Sample Input
7 2 1 4 5 1 3 3
4 1000 1000 1000 1000
0
Sample Output8
4000
【問題解決の考え方】: , ,
コード:// C
#ifndef _GLIBCXX_NO_ASSERT
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if __cplusplus >= 201103L
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
// C++
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include