黑掉的一定是一个长度为$\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的更多相关文章

  1. BZOJ 4123 [Baltic2015] Hacker 解题报告

    首先,Alice 会选择一个长度为 $\lfloor\frac{n+1}{2}\rfloor$ 的区间,我们把这个长度记为 $len$. 有这么一个结论:令 $F_i$ 为覆盖 $i$ 点的所有长度为 ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. The Hacker's Guide To Python 单元测试

    The Hacker's Guide To Python 单元测试 基本方式 python中提供了非常简单的单元测试方式,利用nose包中的nosetests命令可以实现简单的批量测试. 安装nose ...

  4. [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 ...

  5. 装X神器--Hacker Typer

    昨天在伯乐在线看到了这样一篇文章<终于也能像电影中的黑客那样写代码咯>,觉得很酷炫,介绍了一个叫Hacker Typer的工具 网址:http://hackertyper.net/ 在 P ...

  6. Hacker communities collection

    Copy from E安全 Hack Forums: Hack Forums是目前最为理想的黑客技术学习根据地.该论坛不仅在设计上面向黑客群体,同时也适用于开发人员.博主.游戏开发者.程序员.图形设计 ...

  7. 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 ...

  8. 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 ...

  9. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

随机推荐

  1. mysql启动报错(mac)

    $mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ...

  2. 正则匹配之url的匹配

    通过这几天的学习,已经对正则有所了解了. 下面动手写一个匹配url的正则吧. <?php $str="http://www.baidu.com"; $reg="/( ...

  3. Linux shell判断文件和文件夹是否存在

    shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...

  4. com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 3 无效。

    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document fro ...

  5. mybatils多次查询问题

    @Options(flushCache = true, timeout = 20000)

  6. Car的旅行路线(codevs 1041)

    题目描述 Description 又到暑假了,住在城市A的Car想和朋友一起去城市B旅游.她知道每个城市都有四个飞机场,分别位于一个矩形的四个顶点上,同一个城市中两个机场之间有一条笔直的高速铁路,第I ...

  7. Linux vim 底下显示行号

    使用 vim /etc/vimrc 然后进入之后再 set ruler" show the cursor position all the time 底下再加上 set nu 保存退出 :w ...

  8. 菜鸟学Linux命令:grep配合ls等使用

    linux grep命令 (global search regular expression(RE) and print out the line )是一种强大的文本搜索工具,它能使用正则表达式搜索文 ...

  9. jQuery 知识点积累

    1.判断checkbox是否选中   $("#aa").prop("checked")==true2.给属性赋值   $("#aa").pr ...

  10. php 解决和避免form表单重复提交的方法

    在提交表单的时候,可能遇到网速等导致页面突然加载变慢,用户重复地点击提交按钮,将在数据库产生多条数据,导致不可控情况. 比如下面的情况就会导致表单重复提交: 点击提交按钮两次. 点击刷新按钮. 使用浏 ...