zoukankan      html  css  js  c++  java
  • BZOJ——T 1113: [Poi2008]海报PLA

    http://www.lydsy.com/JudgeOnline/problem.php?id=1113

    Time Limit: 10 Sec  Memory Limit: 162 MB
    Submit: 1170  Solved: 792
    [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

    HINT

     

    Source

    宽度并没有什么用。。。

    可以用容斥原理   ans==n-可以省略的个数

    维护一个单调增栈,如果栈中有高度大于下一个高度的,省略个数++

     1 #include <algorithm>
     2 #include <cstdio>
     3 
     4 using namespace std;
     5 
     6 const int N(252333);
     7 int stack[N],top,ans;
     8 
     9 inline void read(int &x)
    10 {
    11     x=0; int ch=getchar();
    12     for(;ch>'9'||ch<'0';) ch=getchar();
    13     for(;ch>='0'&&ch<='9';ch=getchar()) x=ch-'0'+x*10;
    14 }
    15 
    16 int main()
    17 {
    18     int n,w,h; read(n);
    19     ans=n;
    20     for(int i=1;i<=n;i++)
    21     {
    22         read(w),read(h);
    23         for(;top>0&&stack[top]>=h;top--)
    24             if(stack[top]==h) ans--;
    25         stack[++top]=h;
    26     }
    27     printf("%d
    ",ans);
    28     return 0;
    29 }
    ——每当你想要放弃的时候,就想想是为了什么才一路坚持到现在。
  • 相关阅读:
    10046 event 知多少
    10046 event 知多少
    awr相关指标解析
    父子关系展示
    secureCRT启动xmanager图形化工具
    linux单用户模式
    Tor
    windows下的unix工具集:UnxUtils
    OPENLDAP
    Windows命令行重命名文件
  • 原文地址:https://www.cnblogs.com/Shy-key/p/7391431.html
Copyright © 2011-2022 走看看