bzoj1113 [Poi2008]海报PLA
来源:互联网 发布:怎么下载网站的数据库 编辑:程序博客网 时间:2024/05/18 05:03
题目
首先,答案的上界显然就为n。之后考虑如何减少——如果两张海报高度相同,之间的海报都比它高,答案就减少一。
单调队列就可以了。
#include<bits/stdc++.h>#define N 250000using namespace std;int n,tot;int tmp,x;int stk[N+1],top; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline int read(){ int x=0,b=1; char c=nc(); for(;!(c<='9'&&c>='0');c=nc())if(c=='-')b=-1; for(;c<='9'&&c>='0';c=nc())x=x*10+c-'0'; return x*b;}inline void write(int x){ if(x==0)putchar('0'); else { char buf[15]; int len=0; if(x<0)putchar('-'),x=-x; while(x)buf[++len]=x%10+'0',x/=10; for(int i=len;i>=1;i--)putchar(buf[i]); } putchar(' ');}int main(){ freopen("in.txt","r",stdin); n=read(); for(int i=1;i<=n;i++) { tmp=read(),x=read(); while(x<=stk[top])tot+=(x==stk[top--]); stk[++top]=x; } cout<<n-tot; return 0;}
阅读全文
0 0
- 【bzoj1113】[Poi2008]海报PLA
- bzoj1113[Poi2008]海报PLA
- bzoj1113【poi2008】海报PLA
- 【Poi2008】【BZOJ1113】海报PLA
- bzoj1113: [Poi2008]海报PLA
- 【bzoj1113】 [Poi2008]海报PLA
- bzoj1113 [Poi2008]海报PLA
- Bzoj1113:[Poi2008]海报PLA:贪心+单调栈
- [BZOJ1113][Poi2008]海报PLA(单调栈)
- bzoj1113[Poi2008]海报PLA 单调栈
- [bzoj1113][POI2008]海报PLA(单调栈)
- bzoj1113 [Poi2008]海报PLA(单调栈)
- BZOJ1113 海报PLA
- 【单调栈】【bzoj1113】海报PLA
- 1113: [Poi2008]海报PLA
- POI2008 pla(poster)海报
- 1113: [Poi2008]海报PLA
- 【BZOJ 1113】 [Poi2008]海报PLA
- Bigger is Better UVA
- springmvc获取request,response的方法
- Xutils完全解析(四):HttpUtils
- 理解Maven中的SNAPSHOT版本和正式版本
- ipsec Permission denied
- bzoj1113 [Poi2008]海报PLA
- Centos 安装OpenStack
- git cherry-pick用于把另一个本地分支的commit修改应用到当前分支
- JVMGC机制
- 无需Api_Key使用百度在线翻译接口
- bzoj2718 [Violet 4]毕业旅行
- Github使用之将已有项目提交到Github/从Github上pull到本地
- web缓存机制——浏览器缓存
- 局部变量、全局变量、变量、抽象