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 ...
随机推荐
- Python学习笔记(二)在线用pip下载第三方包
根据他人的博客,可以发现pip也是可以离线安装已经下载好的包的,具体请参考<pip常用命令>.由于现在还没进展到那个程度,所以本次博客先记录一下我已经学会的东西. 1.pip基本用法 (1 ...
- intellij idea pycharm phpstorm webstorm 这些编辑器像 sublime text 一样使用 ctrl d 来操作光标多选。
在Windows 和 Linux 快捷键是 Alt+J,在 Mac OS X 系统下快捷键是 Ctrl+G . 参考 https://blog.jetbrains.com/phpstorm/2014/ ...
- 【HTML5开发系列】表单元素
<form> 创建一个HTML表单 属性: action 表示提交表单时浏览器应该把用户填写的数据发送到什么地方 method 用来指定表单数据发送到服务器的方式.允许值有get和post ...
- iOS设备获取总结
1.获取iOS设备的各种信息 // 这个方法后面会列出来 NSString *deviceName = [self getDeviceName]; NSLog(@"设备型号-->%@& ...
- Latent Activity Trajectory (LAT)
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/funcZone_TKDE_Zheng.pdf Specific ...
- What happens when we continue stacking deeper layers on a “plain” convolutional neural network?
http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture9.pdf The deeper model performs worse, but ...
- activiti基础--3-----------------------------流程实例
一.流程实例用到的表: select * from act_ru_execution #正在执行的任务表 select * from act_hi_procinst #流程实例的历史表 select ...
- python3保存一个网页
import requests res = requests.get("http://www.baidu.com") savefile = open("baidu.htm ...
- GPS模块坐标偏差很大?
回答这个问题,首先要了解几个概念: 火星坐标系:天朝有关部门规定,为了保证国家安全,所有的地图公司提供的地图必须对实际的GPS坐标进行一定的偏移,偏移后的GPS坐标系俗称火星坐标系,而这个偏移是不固定 ...
- python selenium cookie 登录
概要: 1.正常登录,使用selenium获取cookie: 2.保存cookie: 3.使用cookie登录. 4.python--2.7,selenium--3.4.1 步骤1 正常登录,使用se ...