PKU 2082 Terrible Sets(单调栈)】的更多相关文章

题目大意:原题链接 一排紧密相连的矩形,求能构成的最大矩形面积. 为了防止栈为空,所以提前加入元素(0,0). #include<cstdio> #include<stack> #define maxn 50005 using namespace std; struct Element { int length; int height; Element(){} Element(int _w,int _h){ length=_w,height=_h; } }e[maxn]; int…
Description Let N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some elements in N, and w0 = 0.  Define set B = {< x, y > | x, y ∈ R and there exists an index i > 0 such…
[题目链接] http://poj.org/problem?id=2082 [题目大意] 给出一些长方形下段对其后横向排列得到的图形,现在给你他们的高度, 求里面包含的最大长方形的面积 [题解] 我们枚举每个位置的最大高度全部被保留时得到的最优解,那么答案一定被包含在其中, 那么题目转化为求出每个高度左右两边最近的比其低的位置,可以用单调栈完成. [代码] #include <cstdio> #include <algorithm> using namespace std; con…
Terrible Sets Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 2747   Accepted: 1389 Description Let N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some element…
Description Let N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some elements in N, and w0 = 0. Define set B = {< x, y > | x, y ∈ R and there exists an index i > 0 such…
题目传送门 题意:紧贴x轴有一些挨着的矩形,给出每个矩形的长宽,问能组成的最大矩形面积为多少 分析:用堆栈来维护高度递增的矩形,遇到高度小的,弹出顶部矩形直到符合递增,顺便计算矩形面积,且将弹出的宽度都累积到当前的矩形中,这样最后再扫描一遍,算面积很方便,这题应该算是 POJ 2559 的强化版了 收获:stack的应用,求矩形面积,矩阵相乘,表达式计算 代码: /************************************************ * Author :Running…
Terrible Sets Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4113 Accepted: 2122 Description Let N be the set of all natural numbers {0 , 1 , 2 , - }, and R be the set of all real numbers. wi, hi for i = 1 - n are some elements in N, and…
Terrible Sets Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5067   Accepted: 2593 Description Let N be the set of all natural numbers {0 , 1 , 2 , . . . }, and R be the set of all real numbers. wi, hi for i = 1 . . . n are some element…
CODEVS 2673:Special Judge 题目描述 Description   这个月的pku月赛某陈没有参加,因为当时学校在考试[某陈经常逃课,但某陈还没有强大到考试也可以逃掉的程度].何况,对于北大校赛,水牛通常是没有什么希望考得好的[事实上某陈最好成绩是仅A了一道题]. 某陈郁闷.接下来他又将沉浸在无穷尽的刷题中,每天面对各种颜色的Status--WA,TLE,RE,甚至还有MLE,CE,PE什么什么的,他无比期待蓝色的AC. 话说RP爆发的某陈弄到了很久以后某次pku月赛的某题…
http://www.lydsy.com/JudgeOnline/problem.php?id=1628 http://www.lydsy.com/JudgeOnline/problem.php?id=1683 又是重复的题.... 单调栈维护递减,然后相同的话矩形-1 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream&g…