Description

N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们.

Input

第一行给出数字N,代表有N个矩形.N在[1,250000] 下面N行,每行给出矩形的长与宽.其值在[1,1000000000]2 1/2 Postering

Output

最少数量的海报数.

Sample Input

5

1 2

1 3

2 2

2 5

1 4

Sample Output

4

HINT




单调递增栈随便搞一下就好

/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline int read(){
int x=0,f=1;char ch=getchar();
for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
inline void print(int x){
if (x>=10) print(x/10);
putchar(x%10+'0');
}
const int N=2.5e5;
int stack[N+10],top;
int main(){
int n=read(),same=0;
for (int i=1;i<=n;i++){
int x=read(),y=read();
while (top&&y<=stack[top]){
if (y==stack[top]) same++;
top--;
}
stack[++top]=y;
}
printf("%d\n",n-same);
return 0;
}

[POI2008]海报PLA的更多相关文章

  1. BZOJ 1113: [Poi2008]海报PLA

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

  2. 1113: [Poi2008]海报PLA

    1113: [Poi2008]海报PLA Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 765  Solved: 466[Submit][Status ...

  3. BZOJ1113 Poi2008 海报PLA【单调栈】【水】

    BZOJ1113 Poi2008 海报PLA Description N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250 ...

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

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

  5. bzoj1113: [Poi2008]海报PLA

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  6. BZOJ1113 [Poi2008]海报PLA 【分治 + 线段树】

    题目链接 BZOJ1113 题解 显然只与高有关,每次选择所有海报中最低的覆盖所有海报,然后分治两边 每个位置会被调用一次,复杂度\(O(nlogn)\) \(upd:\)智障了,,是一道\(O(n) ...

  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-1113】海报PLA 单调栈

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

  9. BZOJ1113 海报PLA

    好像是很古老的题?现在BZOJ上找不到该题,所以没有提交. 1113: [Poi2008]海报PLA Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 8 ...

随机推荐

  1. ArcGIS Engine中的Symbols详解

    转自原文ArcGIS Engine中的Symbols详解 本文由本人翻译ESRI官方帮助文档.尊重劳动成果,转载请注明来源. Symbols ArcObjects用了三种类型的Symbol(符号样式) ...

  2. Excel中INDEX函数的使用

    1 函数INDEX( )有两种形式: 数组形式——INDEX(array,row_num,column_num)和 引用形式——INDEX(reference,row_num,column_num,a ...

  3. Android Activity与远程Service的通信学习总结

    当一个Service在androidManifest中被声明为 process=":remote", 或者是还有一个应用程序中的Service时,即为远程Service, 远程的意 ...

  4. 看懂JSP声明的格式。。。

    在WebRoot下新建test3.jsp 改动body内容: <%! int a = 3; %>     <% int b = 3; %>     <%= a--  %& ...

  5. react-loadable 进行代码分割的基本使用

    由上篇文章我们可以知道,我的项目,打包后的 js 是 7M 的,首屏就加载 7M 的文件虽然没什么特别大的缺点,但总不是最优的解决办法 因此我们用到了 react-router4 的 react-lo ...

  6. Android开发pool解析xml

    xml在开发中的作用不可小觑,很多时候我们都要用到这种文件,所以学习它的解析方式很是必要. 我们都知道java中xml的解析有:dom,SAX,但是Android下我们使用pool解析,是更为方便,而 ...

  7. [学习笔记]渗透测试metasploit

    1.渗透成功后,在meterpreter命令行,需要使用如下命令切换当前目录.更多信息,可以参考: meterpreter > pwd C:\ meterpreter > cd /&quo ...

  8. ABAP ALV F4帮助

    ALV F4帮助, 选值保存到ALV. TYPE-POOLS:slis. CLASS lcl_event_receiver DEFINITION DEFERRED. DATA: gt_fcat TYP ...

  9. android8 Notification

     界面Layout:  customnotice.xml <?xml version="1.0" encoding="utf-8"?> <Li ...

  10. Serializable and XmlEnum

    The easiest way is to use [XmlEnum] attribute like so: [Serializable] public enum EnumToSerialize { ...