黑掉的一定是一个长度为$\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. 今天逛VC驿站 的收获

    1.C++ 如何定义一个定长字符串, 若不足位数,就补字符串"0"? eg: CString str1 = “123”;不足20位,前面补“0”,实现效果为“00000000000 ...

  2. 初中数学题归纳w

    刷完了一张代数 P1 计算 $\left( \frac{1}{1}-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+...+\frac{1}{2011}- \frac{1}{2 ...

  3. How to: Set up Openswan L2TP VPN Server on CentOS 6

    Have you ever wanted to set up your own VPN server? By following the steps below, you can set up you ...

  4. Linux 系统安全 抵御TCP的洪水

    抵御TCP的洪水 分类: LINUX tcp_syn_retries :INTEGER默认值是5对 于一个新建连接,内核要发送多少个 SYN 连接请求才决定放弃.不应该大于255,默认值是5,对应于1 ...

  5. FastCgi与PHP-fpm之间是个什么样的关系

    刚开始对这个问题我也挺纠结的,看了<HTTP权威指南>后,感觉清晰了不少. 首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者. ...

  6. Ubuntu 更改文件夹权限及chmod详细用法

    转自: http://blog.chinaunix.net/uid-21880738-id-1813031.html 对Document/目录下的所有子文件与子目录执行相同的权限变更: Documen ...

  7. 【Python】python代码如何调试?

    Python 程序如何高效地调试? 现在我在debug python程序就只是简单在有可能错误的地方print出来看一下,不知道python有没像c++的一些IDE一样有单步调试这类的工具?或者说各位 ...

  8. python声明文件编码,必须在文件的第一行或第二行

    #coding=utf-8和# -*- coding: utf-8 -*-的作用 – 指定文件编码类型 注意的两点: 1.声明必须在文件的第一行或第二行: 2.coding后面必须紧跟冒号或等号,#c ...

  9. shell脚本去重的几种方法

    测试文件 [root@bogon ~]# cat >test jason jason jason fffffjason 按 Ctr + D保存 1.sort -u [root@bogon ~]# ...

  10. TinyMCE textarea 输入框外部程序动态修改方法

    TinyMCE textarea 输入框外部程序动态修改方法 Public Function C2IE_TINYMCE(ByVal id As String, ByVal value As Strin ...