题意:坐标轴上有连续的n个底均为1,高为h[i]的矩形,求能够构成的最大矩形的面积. 学习的别人的代码 @_@ 看底的坐标怎么找的看了好一会儿--- 记l[i]为矩形的底的左边的坐标,就将它一直向左扩展 记r[i]为矩形的底的右边的坐标(倒着找,从n开始找,题解里面还着重强调了要倒着找,要不然就体现不出优化了)至于那个优化,我想的是,每一次算r[i]的时候,它前面的一个r[i]就是覆盖得最远的了,可以减少计算(用了一组样例试验) 然后就枚举找出面积的最大值-- #include<iostream…
E - Largest Rectangle in a Histogram Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1506 Appoint description: Description A histogram is a polygon composed of a sequence of rectangles aligned a…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1506 题目: Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18833    Accepted Submission(s): 5636 Problem Description…
题目链接 对栈的一种灵活运用吧算是,希望我的注释写的足够清晰.. #include<bits/stdc++.h> using namespace std; typedef long long LL; ; int Stack[N]; //Stack[]为单调栈(即每次能入栈的元素值必比栈顶元素(若存在)要大) int len[N]; //len[]与Stack[]同步 ,记录的是从Stack[]中对应元素起向左最大可延伸的宽度 int n; LL top,ans,h; void print()…
题意: 有一个柱状图,有N条柱子.每一条柱子宽度都为1,长度为h1...hN. 在这N条柱子所构成的区域中找到一个最大面积,每平方米3块钱,问最多赚多少钱. 输入: 1<=N<=100000 0<=hi<=1000000000 思路: N很大,肯定得用一个O(N)或O(NLOGN)的算法,, 假如这个面积的长是从第i条柱子到第j条柱子,宽则一定是第i条柱子到第j条柱子中最矮的那条柱子的高度. 而我们站在那根最矮的柱子向左看,第i-1条的柱子一定是小于当前柱子的,否则可以加进去.向右…
Largest Rectangle in a Histogram Problem 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 sh…
题目链接:HDU - 1506 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…
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 rectang…
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11706    Accepted Submission(s): 3219 Problem Description A histogram is a polygon composed of a sequence of rec…
                                                                                                   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…