A11763 | Castle Defense
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Today you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a long wall that is split into $n$ sections. At this moment there are exactly $a_{i}$ archers located at the $i$ -th section of this wall. You know that archer who stands at section $i$ can shoot orcs that attack section located at distance not exceeding $r$ , that is all such sections $j$ that $|i-j|<=r$ . In particular, $r=0$ means that archers are only capable of shooting at orcs who attack section $i$ .
Denote as defense level of section $i$ the total number of archers who can shoot at the orcs attacking this section. Reliability of the defense plan is the minimum value of defense level of individual wall section.
There is a little time left till the attack so you can't redistribute archers that are already located at the wall. However, there is a reserve of $k$ archers that you can distribute among wall sections in arbitrary way. You would like to achieve maximum possible reliability of the defence plan.
Denote as defense level of section $i$ the total number of archers who can shoot at the orcs attacking this section. Reliability of the defense plan is the minimum value of defense level of individual wall section.
There is a little time left till the attack so you can't redistribute archers that are already located at the wall. However, there is a reserve of $k$ archers that you can distribute among wall sections in arbitrary way. You would like to achieve maximum possible reliability of the defence plan.
输入格式
The first line of the input contains three integers $n$ , $r$ and $k$ ( $1<=n<=500000$ , $0<=r<=n$ , $0<=k<=10^{18}$ ) — the number of sections of the wall, the maximum distance to other section archers can still shoot and the number of archers yet to be distributed along the wall. The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=10^{9}$ ) — the current number of archers at each section.
输出格式
Print one integer — the maximum possible value of defense plan reliability, i.e. the maximum possible value of minimum defense level if we distribute $k$ additional archers optimally.
输入输出样例
输入 #1
5 0 6 5 4 3 4 9
输出 #1
5
输入 #2
4 2 0 1 2 3 4
输出 #2
6
输入 #3
5 1 1 2 1 2 1 2
输出 #3
3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted