CF954G.Castle Defense

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn sections. At this moment there are exactly aia_{i} archers located at the ii -th section of this wall. You know that archer who stands at section ii can shoot orcs that attack section located at distance not exceeding rr , that is all such sections jj that ij<=r|i-j|<=r . In particular, r=0r=0 means that archers are only capable of shooting at orcs who attack section ii .

Denote as defense level of section ii 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 kk 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 nn , rr and kk ( 1<=n<=5000001<=n<=500000 , 0<=r<=n0<=r<=n , 0<=k<=10180<=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 nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=1090<=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 kk 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
    
首页