博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Poj 2082 Terrible Sets
阅读量:5116 次
发布时间:2019-06-13

本文共 1979 字,大约阅读时间需要 6 分钟。

Terrible Sets
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 5466 Accepted: 2792
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 that 0 <= y <= hi ,∑0<=j<=i-1wj <= x <= ∑0<=j<=iwj} 
Again, define set S = {A| A = WH for some W , H ∈ R+ and there exists x0, y0 in N such that the set T = { < x , y > | x, y ∈ R and x0 <= x <= x0 +W and y0 <= y <= y0 + H} is contained in set B}. 
Your mission now. What is Max(S)? 
Wow, it looks like a terrible problem. Problems that appear to be terrible are sometimes actually easy. 
But for this one, believe me, it's difficult.
Input
The input consists of several test cases. For each case, n is given in a single line, and then followed by n lines, each containing wi and hi separated by a single space. The last line of the input is an single integer -1, indicating the end of input. You may assume that 1 <= n <= 50000 and w1h1+w2h2+...+wnhn < 109.
Output
Simply output Max(S) in a single line for each case.
Sample Input
3
1 2
3 4
1 2
3
3 4
1 2
3 4
-1
Sample Output
12

14

题意,找面积最大的矩形,手滑一下点到讨论区,然后就开心的使用单调栈的模版。

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define maxn 100000#define maxm 10000005#define MAXN 100005#define MAXM 10005#define mem(a,b) memset(a,b,sizeof(a))#define ll long long#define inf 0x3f3f3f3fusing namespace std;int h[maxn+10];int l[maxn+10],r[maxn+10];int st[maxn+10];int sum[maxn+10];int n;void solve(){ int t=0; for(int i=0;i
0&&h[st[t-1]]>=h[i]) t--; l[i]=t==0?0:(st[t-1]+1); st[t++]=i; } t=0; for(int i=n-1;i>=0;i--){ while(t>0&&h[st[t-1]]>=h[i]) t--; r[i]=t==0?n:st[t-1]; st[t++]=i; } ll res=0; for(int i=0;i

转载于:https://www.cnblogs.com/da-mei/p/9053220.html

你可能感兴趣的文章
centos 7 redis-4.0.11 主从
查看>>
博弈论 从懵逼到入门 详解
查看>>
永远的动漫,梦想在,就有远方
查看>>
springboot No Identifier specified for entity的解决办法
查看>>
慵懒中长大的人,只会挨生活留下的耳光
查看>>
"远程桌面连接--“发生身份验证错误。要求的函数不受支持
查看>>
【BZOJ1565】 植物大战僵尸
查看>>
VALSE2019总结(4)-主题报告
查看>>
浅谈 unix, linux, ios, android 区别和联系
查看>>
51nod 1428 活动安排问题 (贪心+优先队列)
查看>>
中国烧鹅系列:利用烧鹅自动执行SD卡上的自定义程序(含视频)
查看>>
Solaris11修改主机名
查看>>
latex for wordpress(一)
查看>>
如何在maven工程中加载oracle驱动
查看>>
Flask 系列之 SQLAlchemy
查看>>
aboutMe
查看>>
【Debug】IAR在线调试时报错,Warning: Stack pointer is setup to incorrect alignmentStack,芯片使用STM32F103ZET6...
查看>>
一句话说清分布式锁,进程锁,线程锁
查看>>
python常用函数
查看>>
FastDFS使用
查看>>