bzoj 1628: [Usaco2007 Demo]City skyline 单调队列
来源:互联网 发布:linux root防破解 编辑:程序博客网 时间:2024/06/05 01:53
题意
分析
sb题。只要维护一个单调递增的单调队列即可。
代码
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;int q[50005];int main(){ int w,n; scanf("%d%d",&n,&w); int head=1,tail=1,ans=0; for (int i=1;i<=n;i++) { int x,y; scanf("%d%d",&x,&y); while (head<=tail&&q[tail]>y) tail--; if (y!=q[tail]) ans++,q[++tail]=y; } printf("%d",ans); return 0;}
阅读全文
0 0
- bzoj 1628: [Usaco2007 Demo]City skyline 单调队列
- 【BZOJ】1628 [Usaco2007 Demo]City skyline 单调栈
- BZOJ 1628: [Usaco2007 Demo]City skyline
- 贪心-BZOJ-1628-[Usaco2007 Demo]City skyline
- [bzoj] 1628: [Usaco2007 Demo]City skyline
- BZOJ 1628: [Usaco2007 Demo]City skyline
- bzoj1628: [Usaco2007 Demo]City skyline(单调队列)
- [单调栈] BZOJ 1113 [Poi2008]海报PLA & BZOJ 1628 [Usaco2007 Demo]City skyline
- 1628: [Usaco2007 Demo]City skyline
- bzoj 1628 && 1683: [Usaco2007 Demo]City skyline(模拟)
- bzoj1628 [Usaco2007 Demo]City skyline
- 【BZOJ1628】【USACO2007 Demo】City Skyline
- bzoj1628【Usaco2007 Demo】City skyline
- City Skyline --(单调队列)
- City Skyline(单调队列)
- [BZOJ1628]=[BZOJ1683][Usaco2007 Demo]City skyline
- BZOJ 1683: [Usaco2005 Nov]City skyline 城市地平线 还是单调栈。。。
- poj 3044 City Skyline 单调栈
- 自定义密码输入框(passwordEditText)
- windows安装TortoiseGit详细使用教程【基础篇】
- CUDA入门
- 常用工具类总结
- 自动生成model
- bzoj 1628: [Usaco2007 Demo]City skyline 单调队列
- insert into select 语句
- Myeclipse最简易安装jad反编译插件,带工具
- JavaWeb笔记(7)
- string类中,利用构造方法,实现实例化
- 安装ubuntu后找不到win
- Ubuntu 10.10下的飞鸽传书-iptux
- 容器核心技术详解
- 大型分布式系统的优化解决方案