poj2082 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…
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…
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…
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…
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…
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…
[题目链接] http://poj.org/problem?id=2082 [题目大意] 给出一些长方形下段对其后横向排列得到的图形,现在给你他们的高度, 求里面包含的最大长方形的面积 [题解] 我们枚举每个位置的最大高度全部被保留时得到的最优解,那么答案一定被包含在其中, 那么题目转化为求出每个高度左右两边最近的比其低的位置,可以用单调栈完成. [代码] #include <cstdio> #include <algorithm> using namespace std; con…
本来实在做后缀数组的题目的,不巧,碰到了pku3415这题,需要用到单调栈来维护,但是之前又没有学习过单调栈这方面的知识,于是水了几题....... 题意:给你一些连续的小矩形,高宽不定,求最大的矩形面积........ 思路:直接用单调栈,当有一个矩形的高小于等于栈顶元素的高时,出栈,并维护这个即将入栈的元素的向前延伸的宽度范围,维护出栈后的栈顶元素向后延伸的宽度范围....... #include<iostream> #include<stack> #include<st…
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…
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…