bzoj1113: [Poi2008] Poster pla

Source: Internet
Author: User

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 #defineMAXN 2500057 using namespacestd;8 9 intN,top,stack[maxn],ans;Ten  One intMain () { A     intu,v; -scanf"%d",&n); -top=ans=0, memset (Stack,0,sizeof(stack)); the      for(intI=1; i<=n;i++){ -scanf"%d%d",&u,&v); -          while(TOP&AMP;&AMP;STACK[TOP]&GT;V) top--; -stack[++top]=v; +         if(stack[top]!=stack[top-1]) ans++; -     } +printf"%d\n", ans); A     return 0; at}
View Code

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

The main topic: n rectangles, lined up in a row. Now you want to cover them with as few rectangular posters as possible.

Practice: The question, the problem is obviously only related to the high, if there are two matrices of high equality, and the matrix between them is not less than their height, so that their two matrices only need to use a poster to cover.

So we can use the efficient monotone stack to maintain.

bzoj1113: [Poi2008] Poster pla

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.