BZOJ4123 : [Baltic2015]Hacker
黑掉的一定是一个长度为$\lfloor\frac{n+1}{2}\rfloor$的区间。
于是枚举初始点,然后查询包含它的区间的最小值。
通过维护前后缀最小值+单调队列$O(n)$解决。
#include<cstdio>
#define N 500010
int n,k,i,a[N<<1],s[N],pre[N],suf[N],q[N],h,t,ans;
inline void read(int&a){char c;while(!(((c=getchar())>='0')&&(c<='9')));a=c-'0';while(((c=getchar())>='0')&&(c<='9'))(a*=10)+=c-'0';}
inline void max(int b){if(ans<b)ans=b;}
inline int min(int a,int b){return a<b?a:b;}
int main(){
read(n);k=(n+1)/2-1;
for(i=1;i<=n;i++)read(a[i]),a[i+n]=a[i];
for(i=2;i<=n*2;i++)a[i]+=a[i-1];
for(i=1;i<=n;i++)s[i]=a[i+k]-a[i-1];
for(pre[0]=s[i=1];i<=n;i++)pre[i]=min(pre[i-1],s[i]);
for(suf[n+1]=s[i=n];i;i--)suf[i]=min(suf[i+1],s[i]);
for(h=i=1;i<=k;q[++t]=i++){
max(min(pre[i],suf[i+n-k]));
while(h<=t&&s[q[t]]>=s[i])t--;
}
for(;i<=n;i++){
while(h<=t&&s[q[t]]>=s[i])t--;q[++t]=i;
while(i-q[h]>k)h++;
max(s[q[h]]);
}
return printf("%d",ans),0;
}
BZOJ4123 : [Baltic2015]Hacker的更多相关文章
- BZOJ 4123 [Baltic2015] Hacker 解题报告
首先,Alice 会选择一个长度为 $\lfloor\frac{n+1}{2}\rfloor$ 的区间,我们把这个长度记为 $len$. 有这么一个结论:令 $F_i$ 为覆盖 $i$ 点的所有长度为 ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- The Hacker's Guide To Python 单元测试
The Hacker's Guide To Python 单元测试 基本方式 python中提供了非常简单的单元测试方式,利用nose包中的nosetests命令可以实现简单的批量测试. 安装nose ...
- [COPY] How to become a hacker
Engish version copied from here Why This Document? As editor of the Jargon File and author of a few ...
- 装X神器--Hacker Typer
昨天在伯乐在线看到了这样一篇文章<终于也能像电影中的黑客那样写代码咯>,觉得很酷炫,介绍了一个叫Hacker Typer的工具 网址:http://hackertyper.net/ 在 P ...
- Hacker communities collection
Copy from E安全 Hack Forums: Hack Forums是目前最为理想的黑客技术学习根据地.该论坛不仅在设计上面向黑客群体,同时也适用于开发人员.博主.游戏开发者.程序员.图形设计 ...
- Five More Hacker Tools Every CISO Should Understand
As we mentioned in the first article, Top Five Hacker Tools Every CISO Should Understand, the role o ...
- Top Five Hacker Tools Every CISO Should Understand
As the role of the CISO continues to evolve within organizations towards that of an executive level ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
随机推荐
- Coursera台大机器学习课程笔记10 -- Linear Models for Classification
这一节讲线性模型,先将几种线性模型进行了对比,通过转换误差函数来将linear regression 和logistic regression 用于分类. 比较重要的是这种图,它解释了为何可以用Lin ...
- poj1753枚举
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 33670 Accepted: 14713 Descr ...
- Python的getattr()
Python的getattr(),setattr(),delattr(),hasattr() getattr()函数是Python自省的核心函数,具体使用大体如下: 获取对象引用getattrGeta ...
- Xenomai
http://blog.csdn.net/robertsong2004/article/details/43889249 嵌入式系统的开发,如果对实时性要求不高,就可以使用Linux自身的实时补丁实现 ...
- net发送邮件
对于.NET而言,从2.0开始,发邮件已经是一件非常easy 的事了.下面我给出一个用C#群发邮件的实例,做了比较详细的注解,希望对有需要的朋友有所help.看了这篇BLOG,如果你还不会用.NET发 ...
- Java for LeetCode 058 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- hp unix_ssh
http://www.cyberciti.biz/faq/howto-hpux-sshd-service-startup-shutdown/ http://searchnetworking.techt ...
- errno 错误码
转自:http://baike.baidu.com/link?url=uX-q7K-TTL-5AFNT-hjhAP6fvgAwvsNkIMqJqJ3GEspYgtQXsovEEzpqmQ3ZmAgql ...
- Jil序列化JSON
使用Jil序列化JSON提升Asp.net web api 性能 JSON序列化无疑是Asp.net web api 里面性能提升最重要的一环. 在Asp.net web api 里面我们可以插入 ...
- hdu 4585 map **
题意: Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every ...