bzoj 1113 海报pla
Description
Input
Output
Sample Input
1 2
1 3
2 2
2 5
1 4
Sample Output


【解析】
单调增栈
显然只需要看矩形的高就可以了
当存在两个矩形的高相同且这两个矩形之间没有比他们更矮的矩形
这两个矩形可以用一个海报来覆盖
就需要维护一个单增序列找左边第一个小于它的值
【code】
#include<iostream>
#include<cstdio>
using namespace std;
#define N 250005
int n,top,ans,l,h;
int sta[N];
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&l,&h);
while(top&&sta[top]>h)top--;
sta[++top]=h;
if(sta[top-]!=sta[top])ans++;
}
printf("%d",ans);
return ;
}
bzoj 1113 海报pla的更多相关文章
- BZOJ 1113 海报 单调栈
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1113 题目大意: N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. ...
- BZOJ 1113: [Poi2008]海报PLA
1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1025 Solved: 679[Submit][Statu ...
- bzoj 1113 [Poi2008]海报PLA 单调栈
[Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1304 Solved: 896[Submit][Status][Dis ...
- 1113: [Poi2008]海报PLA
1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 765 Solved: 466[Submit][Status ...
- BZOJ1113 海报PLA
好像是很古老的题?现在BZOJ上找不到该题,所以没有提交. 1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 8 ...
- 【BZOJ-1113】海报PLA 单调栈
1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 896 Solved: 573[Submit][Status ...
- BZOJ1113 Poi2008 海报PLA【单调栈】【水】
BZOJ1113 Poi2008 海报PLA Description N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250 ...
- BZOJ——T 1113: [Poi2008]海报PLA
http://www.lydsy.com/JudgeOnline/problem.php?id=1113 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: ...
- bzoj1113: [Poi2008]海报PLA
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
随机推荐
- 记CBS一次动人心魄的数据保卫战
接触分布式存储已经有一年多的时间了,首次遇到存储侧三份数据都有异常的情况,三份数据异常意味着客户数据的丢失,这个对云存储来讲是致命的打击.为了保证数据的安全,CBS运维和开发的同学进行了持续两天一夜的 ...
- CAFFE学习笔记(一)Caffe_Example之训练mnist
0.参考文献 [1]caffe官网<Training LeNet on MNIST with Caffe>; [2]薛开宇<读书笔记4学习搭建自己的网络MNIST在caffe上进行训 ...
- POJ 2187 Beauty Contest【凸包周长】
题目: http://poj.org/problem?id=1113 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- 九度OJ 1001:A+B for Matrices
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:17682 解决:7079 题目描述: This time, you are supposed to find A+B where A and ...
- ubuntu下操作端口的方法
最简单的一个操作:sudo ufw status可检查防火墙的状态,我的返回的是:不活动 sudo ufw version防火墙版本: ufw 0.29-4ubuntu1 Copyright 2008 ...
- C#读取excel 找不到可安装的ISAM
实在没有办法了 就仔细的查看了 一下数据链接字符串: string strConn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" ...
- zipfile.BadZipFile: File is not a zip file
zipfile.BadZipFile: File is not a zip file 出现这个问题一般是文件损坏的可能性比较大
- foreign key
http://sevenseacat.net/2015/02/24/add_foreign_key_gotchas.html https://robots.thoughtbot.com/referen ...
- Python 3 常用模块之 一
Python 3 模块 一. time模块 时间模块 在Python中,通常有这几种方式来表示时间: 1.1 时间戳(timestamp): 通常来说,时间戳表示的是从1970年1月1日00:00: ...
- RabbitMQ之Exchange Topics模式
说明:此模式实在路由key模式的基础上,使用了通配符来管理消费者接收消息.生产者P发送消息到交换机X,type=topic,交换机根据绑定队列的routing key的值进行通配符匹配: 符号#:匹配 ...