bzoj1113[Poi2008]海报PLA

来源:互联网 发布:p2p网络摄像机怎么用 编辑:程序博客网 时间:2024/04/29 19:42

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


 用单调栈水过了……根本不知道第一维的x有什么用

#include<iostream>#include<cstdio>using namespace std;int zhan[250001];int top,a,n,sum;int main(){scanf("%d",&n);for (int i=1;i<=n;i++){scanf("%d%d",&a,&a);while (top && zhan[top]>=a){if (a==zhan[top]) sum++;top--;}zhan[++top]=a;}printf("%d",n-sum);}


0 0
原创粉丝点击