思路:对于两张高度一样的海报 i, j, 即 y[ i ] = y[ j ], 如果对于任意i < k < j 有y[ k ] > y[ i ] && y[ k ] > y[ j ] 那么i 和 j 就能用同一张海报覆盖

那么我们就能用单调栈维护这个过程。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define piii pair<int, pair<int,int> > using namespace std; const int N = 3e5 + ;
const int M = + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; int n, x[N], y[N], sk[N], head, rear;
int main() {
scanf("%d", &n);
for(int i = ; i <= n; i++) {
scanf("%d%d", &x[i], &y[i]);
} int ans = n; for(int i = ; i <= n; i++) {
while(head < rear && y[i] <= sk[rear - ]) {
if(sk[rear - ] == y[i]) ans--;
rear--;
} sk[rear++] = y[i];
} printf("%d\n", ans);
return ;
}
/*
*/

bzoj 1113的更多相关文章

  1. BZOJ 1113: [Poi2008]海报PLA

    1113: [Poi2008]海报PLA Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1025  Solved: 679[Submit][Statu ...

  2. BZOJ 1113 海报 单调栈

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1113 题目大意: N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. ...

  3. bzoj 1113 [Poi2008]海报PLA 单调栈

    [Poi2008]海报PLA Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1304  Solved: 896[Submit][Status][Dis ...

  4. bzoj 1113 海报pla

    Description N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250000] 下面N行,每行给出矩形的长与宽.其值 ...

  5. BZOJ 1113 Wall ——计算几何

    凸包第一题. 自己认为自己写的是Andrew 其实就是xjb写出来居然过掉了测试. 刚开始把pi定义成了int,调了半天 #include <map> #include <cmath ...

  6. [原博客] POI系列(1)

    正规.严谨.精妙. -POI 发现POI(波兰信息学奥赛)的题都很有意思.于是开刷bzoj上的poi题目(按ac人数降序..).顺手写一写题解,加深印象. 为了防止一篇文章过于长,打算每五道题另起一篇 ...

  7. BZOJ——T 1113: [Poi2008]海报PLA

    http://www.lydsy.com/JudgeOnline/problem.php?id=1113 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: ...

  8. BZOJ 2127: happiness [最小割]

    2127: happiness Time Limit: 51 Sec  Memory Limit: 259 MBSubmit: 1815  Solved: 878[Submit][Status][Di ...

  9. BZOJ 3275: Number

    3275: Number Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 874  Solved: 371[Submit][Status][Discus ...

随机推荐

  1. nginx优化--gzip压缩与expire浏览器缓存

    gzip压缩 概述 网页在服务器端经过了gzip或者其他格式的压缩后的输出明显减少了content-length字节,当访问过百万时,这些减少的字节就会变为客观的流量给节约下来;从而减轻服务器的压力以 ...

  2. php整理

    linux上安装php配套环境有些繁琐 推荐使用一键安装: https://lnmp.org/install.html phalcon框架环境: centos7下php7.0.x安装phalcon框架

  3. advanced bash shell guide读书笔记

    http://note.youdao.com/noteshare?id=fc23a679849b4627d131d3ef07c74a71

  4. RabbitMQ的基础介绍

    转自:http://blog.csdn.net/whycold/article/details/41119807 一.引言 你是否遇到过两个(多个)系统间需要通过定时任务来同步某些数据?你是否在为异构 ...

  5. 「Django」rest_framework学习系列-用户认证

    用户认证:1.项目下utils文件写auth.py文件 from rest_framework import exceptions from api import models from rest_f ...

  6. Bootsrap 直接使用

    Bootstrap3 直接使用 <!DOCTYPE html> <html> <head> <title>Bootstrap3</title> ...

  7. php基础知识(语法与原理)

    一.php简介 PHP超文本预处理器.是嵌入HTML文件中的服务器脚本程序. PHP代码标记:<?php …. ?> PHP文件的扩展名:.php PHP文件的执行:必须从域名开始访问 P ...

  8. Emacs ^ Vim

    Emacs存活: http://files.cnblogs.com/files/TheRoadToTheGold/Emacs%E2%80%94%E2%80%94%E5%AD%98%E6%B4%BB.z ...

  9. Anagrams by Stack(深度优先搜索)

    ZOJ Problem Set - 1004 Anagrams by Stack Time Limit: 2 Seconds      Memory Limit: 65536 KB How can a ...

  10. Shiro实战教程(二)

    http://www.jianshu.com/p/6786ddf54582/ https://www.cnblogs.com/ealenxie/p/10610741.html