poj2082
来源:互联网 发布:linux下i2c应用层读写 编辑:程序博客网 时间:2024/06/07 04:00
http://poj.org/problem?id=2082
题意蛮难懂的 其实和poj2559(有图示)一样的
碰到很多次了..
#include<cstdio>#define MAX(a,b) (a>b?a:b)struct {int w,h;}a[50005];struct{int pos,len;}l[50005],r[50005];int n;void solve(){for(int i=1;i<=n;i++){l[i].len=a[i].w;int j=i-1;while(j>0&&a[i].h<=a[j].h){l[i].len+=l[j].len;j=l[j].pos;}l[i].pos=j;}for(int i=n;i>=1;i--){r[i].len=a[i].w;int j=i+1;while(j<n+1&&a[i].h<=a[j].h){r[i].len+=r[j].len;j=r[j].pos;}r[i].pos=j;}int ans=0;for(int i=1;i<=n;i++){int t=a[i].h*(l[i].len+r[i].len-a[i].w);ans=MAX(ans,t);}printf("%d\n",ans);}int main(){while(scanf("%d",&n)==1&&n!=-1){for(int i=1;i<=n;i++)scanf("%d%d",&a[i].w,&a[i].h);solve();}return 0;}
0 0
- poj2082
- poj2082 stack
- POJ2082 最大矩形面积
- poj2082单调栈
- POJ2082(简单堆栈)
- 见微知著----POJ2082(堆栈)
- poj2082 Terrible Sets
- poj2082(单调栈)
- POJ2599+POJ2082【最大矩形面积】
- poj2082 Terrible Sets 单调栈
- POJ2082---Terrible Sets(单调栈)
- poj2082 连续矩形最大面积
- POJ2082--Terrible Sets(栈)
- poj2082栈的简单应用
- POJ2082 Terrible Sets [DP 单调栈]
- 【堆栈】POJ2082-Terrible Sets-【容易题】
- poj2082(Terrible Sets单调栈入门题)
- POJ2082 最大矩形面积 单调栈
- 将博客搬至CSDN
- 10. 封装、继承、多态
- 【Hadoop】Hadoop安装配置(转)
- UVALive 3989 Ladies' Choice(稳定婚姻问题、Gale-Shapley算法)
- 设计模式之装饰模式
- poj2082
- MySql状态查看方法
- Python challenge_3
- html中meta标签的使用
- 线程创建与C/C++运行时库函数的笔记
- C语言基础六_结构体、枚举
- MATLAB中bwlabel函数介绍
- 闰年
- 获取ServerSocket信息的方法及FTP原理