POJ 2082 Terrible Sets】的更多相关文章

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://poj.org/problem?id=2082 [题目大意] 给出一些长方形下段对其后横向排列得到的图形,现在给你他们的高度, 求里面包含的最大长方形的面积 [题解] 我们枚举每个位置的最大高度全部被保留时得到的最优解,那么答案一定被包含在其中, 那么题目转化为求出每个高度左右两边最近的比其低的位置,可以用单调栈完成. [代码] #include <cstdio> #include <algorithm> using namespace std; con…
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…
题目大意:原题链接 一排紧密相连的矩形,求能构成的最大矩形面积. 为了防止栈为空,所以提前加入元素(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: 3017   Accepted: 1561 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…
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…
题目链接:http://poj.org/problem?id=2082 把矩形按照高度一次递增的循序排列,当违反这一规则的时候,更新ans,用新的data替换之前的矩形.然后最后扫一遍. #include <iostream> #include <stack> #include <cstdio> using namespace std; struct rec { int w; ///宽 int h; ///高 } data; int main() { int n; )…
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…