zoukankan      html  css  js  c++  java
  • BZOJ1113: [Poi2008]海报PLA

    题解:  单调栈 对于具有相同高度的墙是可以用一块海报cover的

    #include <bits/stdc++.h>
    const int MAXN=3e5+10;
    using namespace std;
    int a[MAXN],b[MAXN];
    int st[MAXN],ans,tot;
    int main(){
        int n;scanf("%d",&n);ans=n;
        for(int i=1;i<=n;i++){scanf("%d",&b[i]);if(!b[i])ans--;}
        for(int i=1;i<=n;i++){
    	while(tot>0&&st[tot]>b[i]){tot--;}
    	if(tot>0&&st[tot]==b[i])ans--;
    	st[++tot]=b[i];
        }
        printf("%d
    ",ans);
        return 0;
    }
    

    1113: [Poi2008]海报PLA

    Time Limit: 10 Sec  Memory Limit: 162 MB
    Submit: 1415  Solved: 978
    [Submit][Status][Discuss]

    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

  • 相关阅读:
    状态模式
    适配器模式
    观察者模式
    浮点数在内存中的存储方式
    建造者模式
    外观模式
    模版方法模式
    原型模式
    Python 学习笔记6 变量-元组
    Python 学习笔记5 变量-列表
  • 原文地址:https://www.cnblogs.com/wang9897/p/9432932.html
Copyright © 2011-2022 走看看