Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))

st = 0
i = 0
sa = 0
while i+K < N:
    sa += p[i+K]-p[i]
    if sa > 0:
        st = i+1
        sa = 0
    i += 1

psum = p[st:st+K]
for i in range(K):
    psum[i] = (psum[i]+1)/2
print(sum(psum)

Submission status: Runtime Error

Solution code:
import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(int(x) for x in input().split())
sump = []

for i in range(n - k + 1):
    sump.append(sum(p[i: k + i], k))
    sump.extend(np.sum(p[i: k + i]))

print((max(sump) + k) / 2)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
B=[]
C=[]
D=[]
for i in A:
  C.append((1+i)/2)
  B.append(sum(C))
for i in range(k,n):
  D.append(B[i]-B[i-k])
print(max(D))

Submission status: Runtime Error

Solution code:
n, k  = map(int, input().split())
a = list(map(int, input().split()))
b = a.sorted()
pointer = 0
max = b[n-1]
for i in range(n):
  if max == a[i]:
    pointer = i
sum_list = []
for i in range(k):
  sum = a[pointer - i] + a[pointer - i + 1] 
  			+ a[pointer - i + 2] + a[pointer - i + 3]
  sum_list.append(sum)
  
c = sum_list.sorted()
max_sum = c[n-1]
index = 0
for i in range(k):
  if max_sum == sum_list[i]:
    index = i
    
ans = (1 + a[pointer-index])*a[pointer-index]/2 +
		(1 + a[pointer-index+1])*a[pointer-index+1]/2 + 
  		    (1 + a[pointer-index+2])*a[pointer-index+2]/2 + 
    			 (1 + a[pointer-index+3])*a[pointer-index+3]/2
print(ans)

Submission status: Runtime Error

Solution code:
n, k  = map(int, input().split())
a = list(map(int, input().split()))
b = a.sorted()
pointer = 0
max = b[n-1]
for i in range(n):
  if max == a[i]:
    pointer = i
sum_list = []
for i in range(k):
  sum = a[pointer - i] + a[pointer - i + 1] 
  			+ a[pointer - i + 2] + a[pointer - i + 3]
  sum_list.append(sum)
  
c = sum_list.sorted()
max_sum = c[n-1]
index = 0
for i in range(k):
  if max_sum == sum_list[i]:
    index = i
    
ans = (1 + a[pointer-index])*a[pointer-index]/2 +
		(1 + a[pointer-index+1])*a[pointer-index+1]/2 + 
  		    (1 + a[pointer-index+2])*a[pointer-index+2]/2 + 
    			 (1 + a[pointer-index+3])*a[pointer-index+3]/2

Submission status: Runtime Error

Solution code:

A ,B = [int(x) for x in input().split()]
C = [(int(x)+1)/2 for x in input().split()]
ans = 0
count = 0
D = [0]*A
sum = 0
for i in range(A):
    sum += C[i]
    D[i] = sum
    if i >= B:
        dif = sum - D[i-B]
        if dif > ans:
            ans = dif
    
if A==B:
    ans=sum[A-1]
    
print(ans)

Submission status: Runtime Error

Solution code:
A ,B = [int(x) for x in input().split()]
C = [(int(x)+1)/2 for x in input().split()]
ans = 0
count = 0
D = [0]*A
sum = 0
for i in range(A):
    sum += C[i]
    D[i] = sum
    if i >= B:
        dif = sum[i] - D[i-B]
        if dif > ans:
            ans = dif
    
if A==B:
    ans=sum[A-1]
    
print(ans)

Submission status: Runtime Error

Solution code:
n, k = [int(elem) for elem in input().split()]
ps = [int(elem) for elem in input().split()]

exs = []
for p in ps:
  exs.append((1.0+p)/2)
res = [sum(exs[i:i+k]) for i in range(0, n-k)]
print(max(res))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(len(a)):
    b.append((a[i]+1)/2)
for i in range(len(a)-k+1):
    sum=0
    for j in range(i,i+k):
        sum+=b[j]
    if max<=sum:
        max=sum
print(max)

Submission status: Runtime Error

Solution code:
import numpy as np

def wa (n):
    if n<=1:
        return 1
    else:
        return wa(n-1)+n

if __name__ == "__main__":
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    b=[]
    for i in a:
        b.append(wa(i)/i)
    b.sort(reverse=True)
    print(a,b)
    ans=0
    for i in range(3):

        ans+=b[i]
    print(ans)

Submission status: Runtime Error

Solution code:


n,k=map(int,input().split())
#p=np.array(list(map(int,input().split())))
p=list(map(int,input().split()))
def kitaichi(a):
  s=(1+a)/2.
  return s
kp=list(map(kitaichi,p))

#for z in range(0,k):
#	buf[z]=sum(buf[z:k+z])
buf=[0]*(n-k+1)
buf[0]=sum(kp[:k])
for z in range(1,k):
  buf[z]=buf[z-1]-kp[z-1]+kp[z+k-1]
  #buf=[sum(kp[x:k+x]) for x in range(0,int(k/15))]
maxkp=max(buf)
print(maxkp)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p_n = [int(i) for i in input().split()]

def expected(x):
    return (x+1)/2

def test3():
    e_n = list(map(expected, p_n))
    s_n = []
    for i, e in enumerate(e_n):
        if i == 0:
            s_n.append(e)
            continue
        s_n.append(s_n[i-1] + e)
    result = []
    for i in range(len(s_n)):
        if i+k >= n:
            continue
        result.append(s_n[i+k]-s_n[i])
    print(max(result))      

test3()

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    # list of expected value
    e = [(p[j-1]+1)/2.for j in range(1, n+1)]
    # cumulative sum for e
    c_s = np.cumsum(e)
    # sum of range k
    s = c_s[k:] - c_s[:n-k]
    # calculate max of s
    ans = max(s)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import pandas as pd

n, k = map(int, input().split())
p_n = [int(i) for i in input().split()]

def expected(x):
    return (x+1)/2*k

s = pd.Series(list(map(expected, p_n)))

print(s.rolling(window=k).mean().max())

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
d = map(lambda x: (int(x) + 1) / 2, input().split())
ret = sum(d[:k])
tmp = ret
for i in range(k,n):
  tmp = tmp + d[i] - d[i-k]
  ret = max(ret,tmp)
print(ret)

Submission status: Runtime Error

Solution code:
def exp(x):
  ans = 0
  for i in range(x+1):
    ans += i
  return ans / x

n, k = map(int, input().split())
p = list(map(int, input().split()))
  
sum = 0
ans = []
for i in range(k):
  sum += exp(p[i])
ans.append(sum)

for i in range(n-k+1):
  sum -= exp(p[i])
  sum += exp(p[k])
  ans.append(sum)

print(max(ans))

Submission status: Runtime Error

Solution code:
N = list(map(int,input().split()))
n = N[0]
k = N[1]

X = list(map(int,input().split()))

max_val = 0
max_st = 0
for i in range(0,n-k):
  tmp_val = X[i] + X[i+1] + X[i+2]
  if tmp_val >= max_val :
    max_st = i
    max_val = tmp_val

max_p = (1+X[i])/2 + (1+X[i+1])/2 + (1+X[i+2])/2
print(max_p)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
ans = [tmp]
if n == k:
    ans_mae = ans[0].sum()
    print((ans_mae+k)/2)
else:
    for i in range(1,n-k+1):
        tmp = tmp - p[i-1] + p[i+k-1]
        ans.append(tmp)
    print((max(ans)+k)/2)

Submission status: Runtime Error

Solution code:
import  copy
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = []
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(N - K):
    ans_list.append(P_S[i + K] - P_S[i])

print(max(ans_list))

Submission status: Runtime Error

Solution code:
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0.0
for i in range(K,N+1):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)

Submission status: Runtime Error

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
cumulative_sum = []
answer = 0
i = 0
j = 0
sumOfValue = 0
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(len(expected)-k):
    sumOfValue = expected[maxvalue+3] - expected[maxvalue]
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
max=0
t=list(input().split())
for i in range(N-K+1):
    x=0
    for j in range(K):
        x+=int(s[i+j])
    if max<x :
        max=x
print((max+K)/2)

Submission status: Runtime Error

Solution code:
max=0
N=int(input())
K=int(input())
t=list(input().split())
s=[int(n) for n in t]
for i in range(N-K+1):
    x=0
    for j in range(K):
        x+=s[i+j]
    if max<x :
        max=x
print((max+K)/2)

Submission status: Runtime Error

Solution code:
max=0
N=int(input())
K=int(input())
t=list(input().split())
s=[int(n) for n in t]
for i in range(N-K):
    x=0
    for j in range(K):
        x+=s[i+j]
    if max<x :
        max=x
print((max+K)/2)

Submission status: Runtime Error

Solution code:
max=0
N=int(input())
K=int(input())
t=list(input().split())
s=[int(n) for n in t]
for i in range(N-K):
    x=0
    for j in range(K):
        x+=s[i+j]
    if max<x :
        max=x
print((max+4)/2)

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for j in range(k):
    s += e[j]
    j += 1
  if max < s:
    max = s
    
print((max+k)/1.0)

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

e = [(q+1.0)/2 for q in p]

max = 0
for i in range(n-k+1):
  s = e[i]+e[i+1]+e[i+2]
  if max < s:
    max = s
    
print(max)

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
p = [float(e) for e in input().split()]

e = [(q+1.0)/2.0 for q in p]

max = 0
for i in range(n-k+1):
  s = e[i]+e[i+1]+e[i+2]
  if max < s:
    max = s
    
print(max)

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
p = [float(e) for e in input().split()]

e = [(q+1)/2 for q in p]

max = 0
for i in range(n-k+1):
  s = e[i]+e[i+1]+e[i+2]
  if max < s:
    max = s
    
print(max)

Submission status: Runtime Error

Solution code:
n,k = map(float, input().split())
p = [float(e) for e in input().split()]

e = [(q+1)/2 for q in p]

max = 0
for i in range(n-k+1):
  s = e[i]+e[i+1]+e[i+2]
  if max < s:
    max = s
    
print(max)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans_max = 0
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans_max = max(np.sum(p_i) / np.prod(p), ans_max)
print(ans_max)

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans = []
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans.append(np.sum(p_i) / np.prod(p))
print(max(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
p = (np.array(list((map(int, input().split())))) + 1) / 2

ans = 0

for num in range(len(p)):
    tmp = p[num:num+K].sum()
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Runtime Error

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  sum_data += (dice_array[x] * (dice_array[x] + 1)) / 2 / dice_array[x]
  
print(sum_data)

Submission status: Runtime Error

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  cnt = sum(list(range(1, dice_array[x] + 1)))
  sum_data += (cnt / dice_array[x])
  
print(sum_data)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = list(accumulate(evs))
results = [evs[i+K] - evs[i] for i, e in enumerate(evs[:N-K])]
print(sorted(results)[-1])

Submission status: Runtime Error

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    tmp = ans
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  cnt = sum(list(range(1, dice_array[x] + 1)))
  sum_data += (cnt / dice_array[x])
  
print(sum_data)

Submission status: Runtime Error

Solution code:
N=input().split()
p=map(int, input().split())
NN=int(N[0])
MM=int(N[1])
p2=[0.]*(NN-MM+1)
for i in range(NN-MM+1):
    a=0.
    for j in range(MM):
        a=a+(p[i+j]+1)/2
    p2[i]=a
print(max(p2))

Submission status: Runtime Error

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
kitaiti =[(i+1)/2 for i in B]
ans = []
dd = [0]
for i in range(A[0]):
    dd.append(dd[i] + kitaiti[i])
for i in range(A[1] , A[0]):
    ans.append(dd[i] - dd[i - A[1]])
print(max(ans))

Submission status: Runtime Error

Solution code:
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    e_val = [(1 + val) / 2 for val in A]

    # 累積和を算出 (最初は0)
    e_cumsum = [0]
    for i in range(N):
      e_cumsum.append(e_cumsum[i] + e_val[i])

    # 隣接するK個の部分和を取得
    e_sum_k = []
    for i in range(N-K):
      e_sum_k.append(e_cumsum[i+K] - e_cumsum[i])

    return max(e_sum_k)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Runtime Error

Solution code:
n, k = map(int, raw_input().split())
plist = map(int, raw_input().split())

exp_list = [(p + 1) / 2.0 for p in plist]
print max(sum(exp_list[i:i+k]) for i in xrange(n-k))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())

def calculate_Expectation(n):
    n = int(n)
    p = 1/n
    e = p * (n*(n+1)/2)
    return e

E = list(map(calculate_Expectation, input().split()))
S = [0]
for i, e in enumerate(E):
    S.append(S[i]+e)

sum_of_E = []
for left in range(1, N+1-K):
    right = left + K
    sum_of_E.append(S[right]-S[left])
print(max(sum_of_E))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
#さいころの出目の和を集計
for i in range(n):
    p[i]+=1

sdict={}
sdict[0]=p[0]

for i in range(n-1):
	sdict[i+1]=sdict[i]+p[i+1]

j=0
ans=0
while (j+k <=n):
	dif=sdict[j+k]-sdict[j]
	ans=max(dif,ans)
         j+=1
print(ans/2)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
pi = list(map(int, input().split()))

max = 0
maxi = 0
for i in range(N - K):
    tmp = sum(pi[i : i + K - 1])
    if tmp > max:
        max = tmp
        maxi = i

out = 0
for j in range(K)
    exp = (pi[j + maxi] + 1) / 2
    out = out + exp

print(out)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
pi = list(map(int, input().split()))

max = 0
maxi = 0
for i range(N - K):
    sum = pi(i) + pi(i + 1) + pi(i + 2)
    if sum >= max:
        max = sum
        maxi = i

out = 1 + (pi(maxi) - 1) * 0.5 + 1 + (pi(maxi + 1) - 1) * 0.5 + 1 + (pi(maxi + 2) - 1) * 0.5
print(out)

Submission status: Runtime Error

Solution code:
N, K = map(int(input().split()))
pi = list(map(int(x) for x in input().split()))

max = 0
maxi = 0
i = 0
for j range(N - K):
    sum = pi(j) + pi(j + 1) + pi(j + 2)
    if sum >= max:
        max = sum
        maxi = j

out = 1 + (pi(i) - 1) * 0.5 + 1 + (pi(i + 1) - 1) * 0.5 + 1 + (pi(i + 2) - 1) * 0.5
print(out)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
pi = list(int(x) for x in input().split())

max = 0
maxi = 0
for i range(N - K):
    sum = pi(i) + pi(i + 1) + pi(i + 2)
    if sum >= max:
        max = sum
        maxi = i

out = 1 + (pi(i) - 1) * 0.5 + 1 + (pi(i + 1) - 1) * 0.5 + 1 + (pi(i + 2) - 1) * 0.5
print(out)

Submission status: Runtime Error

Solution code:
n = int(input())
l =[]
for i in range(n):
    t = input()
    l.append(t)
s = list(set(l))
d={}
for p in s:
    c = l.count(p)
    d[p] = c

m = max(d.values())
for k,v in d.items():
    if v == m:
        print(k)

Submission status: Runtime Error

Solution code:
kitailist = []
NandK = input()
pi = input()
NandK = NandK.split(' ')
pi = pi.split(' ')
K = int(NandK[1])
for j in range(len(pi)-3):
    p1 = int(pi[j]) ; p2 = int(pi[j+1]) ; p3 = int(pi[j+2])
    kitaiti = (p1 + p2 + p3 + 3)/2
    kitailist.append(kitaiti)
print(max(kitailist))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

from itertools import combinations, startmap


multiple_list = list(combinations(A, 2))
multiple_result_list = list(startmap(lambda x, y: x*y, multiple_list))


result_sorted = sorted(multiple_result_list)

print(result_sorted[K-1])

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print(f'{M:.12f}')

Submission status: Runtime Error

Solution code:
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])
S[0] = sum(P[0:(NK[1])])

for i in range(NK[0] - NK[1] - 1):
    S[i+1] = S[i] - P[i] + P[i+NK[1]]

print((max(S) + NK[1]) / 2)

Submission status: Runtime Error

Solution code:
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])

for i in range(NK[0] - NK[1]):
    S[i] = sum(P[i:i+NK[1]])

print((max(S) + NK[1]) / 2)

Submission status: Runtime Error

Solution code:
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])

for i in range(NK[0] - NK[1]):
    S[i] = (sum(P[i:i+NK[1]]) + NK[1]) / 2

print(max(S))

Submission status: Runtime Error

Solution code:
import numpy as np
n,k=map(int,input().split())
data=np.fromstring(input(),int,sep=' ')
data+=1
cum=data.cumsum()
hoge=cum[k:]-cum[0:-k]
print(hoge.max()/2)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
data=np.fromstring(input(),int,sep=' ')
data+=1
cum=data.cumsum()
hoge=cum[k:]-cum[0:-k]
print(hoge.max()/2)

Submission status: Runtime Error

Solution code:
kitailist = []
NandK = input()
pi = input()
NandK = NandK.split(' ')
pi = pi.split(' ')
K = int(NandK[1])
for j in range(len(pi)-1):
    p1 = int(pi[j]) ; p2 = int(pi[j+1]) ; p3 = int(pi[j+2])
    kitaiti = (p1 + p2 + p3 + 3)/2
    kitailist.append(kitaiti)
print(max(kitailist))

Submission status: Runtime Error

Solution code:
kitailist = []
NandK = input()
pi = input()
NandK = NandK.split(' ')
pi = pi.split(' ')
K = int(NandK[1])
for j in range(len(pi)-1):
    p1 = pi[j] ; p2 = pi[j+1] ; p3 = pi[j+2]
    kitaiti = (p1 + p2 + p3 + 3)/2
    kitailist.append(kitaiti)
print(max(kitailist))

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2




from numpy as np
P_mean = np.array([ret_mean(p) for p in P])
P_accum = np.zeros(N+1)
P_accum[1:] = P_mean.cumsum()

ans = 0
# print(P_accum)
for i in range(N - K + 1):
    j = i + K
    ans = max(ans, P_accum[j] - P_accum[i])
print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())


dices = list(map(int, input().split()))

# 制約より
MAX_DICE = 1000*K

# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos
maxvalue = sum(dices[maxpos:maxpos+K])

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > maxvalue):
        maxpos = pos
        maxvalue = sum(dices[pos:pos+K])

        # 上限
        if maxvalue == MAX_DICE:
            break

# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
(

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split()) #nはサイコロの個数　kは選ぶサイコロの数
p = list(map(int, input().split()))
dice_value = 0
formula =0
expected_value = 0

for i in range(k):
    dice_value = p[i+k]
    formula = (dice_value + 1) / 2
    expected_value += formula

print(expected_value)

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n, k = map(int, input().split())
p_array = np.array(list(map(int, input().split())))
expc = lambda x: (x+1.0)/2.0
p_array = expc(p_array)

p_cum = np.cumsum(p_array)
p_cum_diff = p_cum[k:] - p_cum[0:n-k]
print(max(p_cum_diff))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
p.sort()
y = 0


def f(n):
    if n < 1:
        return n
    return n + f(n - 1)


for j in range(n - k + 1):
    z = 0
    for i in range(k):
        z += p[-i - 1]
    if z > y:
        y = z
        a = 0
        for l in range(k):
            a += f(p[-l - 1]) / p[-l - 1]
    p.pop()

print(a)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
p.sort()
y = 0


def f(n):
    if n < 1:
        return n
    return n + f(n - 1)


for j in range(n - k + 1):
    z = 0
    for i in range(k):
        z += p[-i - 1]
    if z > y:
        y = z
        a = 0
        for l in range(k):
            a += f(p[-l - 1]) / p[-i - 1]
    p.pop()

print(a)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
a.sort()
y = 0


def f(n):
    x = 0
    for i in range(n + 1):
        x += i
    return x / n


for i in range(k):
    y += f(p[-i - 1])

print(y)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (P[i]+1)/2
R = sum(Q[:K])
ans = R
for j in range(N-K):
  R = R - P[j] + P[j+K]
  ans = max(ans,R)
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = []*N
for i in range(N):
  Q[i] = (P[i]+1)/2
R = sum(Q[:K])
ans = R
for j in range(N-K):
  R = R - Q[j] + Q[j+K]
  ans = max(ans,R)
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = [int(input()) for i in range(N)]
Q = []*N
for i in range(N):
  Q[i] = (P[i]+1)/2
R = sum(Q[:K])
ans = R
for j in range(N-K):
  R = R - Q[j] + Q[j+K]
  ans = max(ans,R)
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = [int(input()) for i in range(N)]
Q = []*N
for i in range(N):
  Q[i] = (P[i]+1)/2
R = 0
for j in range(K):
  R += Q[j]
for k in range(N-K):
  R = R - Q[k] + Q[k+K]
  ans = max(R)
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = [int(input()) for i in range(N)]
Q = []*N
for i in range(N):
  Q[i] = (P[i]+1)/2
R = 0
for j in range(K):
  R += Q[j]
for k in range(N-K)
  R = R - Q[k] + Q[k+K]
  ans = max(R)
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(A):
  A[i]=(1+A[i])/2
sum=0
for i in range(0,n-k+1):
  sum=max(sum,sum(A[i:i+k+1]))
print(sum)

Submission status: Runtime Error

Solution code:
import sys
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
P = list(map(int, inputs[1].split()))
EP = [0.5*p + 0.5 for p in P]

Q = []
buffer = sum(EP[:k])
for i in range(k, n):
    buffer += EP[i] - EP[i-k]
    Q.append(buffer)
print(max(Q))

Submission status: Runtime Error

Solution code:
n, k = map(int,input().split())

p = list(map(int,input().split()))

for i in range(n-k):
    if p[i] < p[i+k]:
        ans = p[i+1:k+i+1]
        
ans = sum(ans)
ans = (ans+k)/2

print(ans)

Submission status: Runtime Error

Solution code:
s=sum(S[:K])
dp=[0]*(N-K+1)
dp[0]=s
for i in range(1,N-K+1):
    s=s-S[i-1]+S[i+K-1]
    if s>dp[i-1]:
        dp[i]=s
print((max(dp)+K)/2)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
li = list(map(lambda x:(x+1)/2,li))
wk = 0
nn = n-k+1
kai = [None]*(nn)

for y in range(nn):
    wk = 0
    for x in range(y,k+y):
        wk = wk + li[x]
    kai[x] = wk
 
print(max(kai))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{%.12f}'.format(M))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print(f'{M:.12f}')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += 1 + p[i] / 2

e = M
for i in range(n-k-1):
    e -= 1 + p[i] / 2
    e += 1 + p[i+k+1] / 2
    if e > M:
        M = e
print(f'{M:%.12f}')

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
e=[c[i] for i in range(b)]
for i in range(b-1):
    mn=min(e)
    if mn<=c[i]:
        for j in range(i-b,i+1):
            su=[]
            for n in range(b):
                su.append(c[n+j])
            if sum(su)>sum(e):
                e=su
print(sum([(e[i]+1)/2 for i in range(b)]))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
e=[]
for i in range(a-b):
    sum=0
    for j in range(b):
        sum=(c[i+j]+1)/2+sum
    e.append(sum)
m=max(e)
print(m)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

#そのサイコロの期待値の合計
e_list = []
for i in range(N):
    e_list.append((1+p_list[i])/2.0)

#累積和
s_list = []
for i in range(N):
    s_list.append(sum(e_list[:i+1]))

#隣接するk個の和
for i in range(N-K+1):
    s_sum = s_list[i+K-1] - s_list[i]
    if dst < s_sum:
        dst = s_sum
print(dst)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ex = [0 for _ in range(n)]
    for i in range(n):
        ex[i] = (p[i]+1)/2

    sumex = sum(ex[:k])
    tmp = sum(ex[:k])
    for i in range(n-k):
        tmp = tmp + (ex[i+k] - ex[i])
        sumex = max(sumex, tmp)
    print(sumex)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))

def S(n):
    return n * (n + 1) // 2

for i in range(k):
    ans += S(p[i]) / p[i]

for i in range(k, n):
    ans = max(ans, ans + S(p[i]) / p[i] - S(p[i - k]) / p[i - k])
    
print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
 
def S(n):
  return n * (n + 1) // 2

for i in range(k):
  ans += S(p[i]) / p[i]

for i in range(k, n):
  ans = max(ans, ans + S(p[i]) / p[i] - S(p[i - k] / p[i - k])
  
print(ans)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))

def S(n):
  return n * (n + 1) // 2

b = 0
s = sum(p[:k])
for i in range(k, n):
  tmp = s - p[i - k] + p[i]
  if tmp > s:
    s = tmp
    b = i
ans = 0
for i in range(b, b + k):
  ans += S(p[i]) / p[i]
  
print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
d=c.copy()
d.sort()
m=d[len(d)-1]
n=[]
s=0
for i in range(1,m+1):
    s=i+s
    n.append(s/i)
for l,i in enumerate(q):
    d[l]=n[i-1]
d.sort(reverse=True)
sum=0
for i in range(b):
    sum=d[i]+sum
print(sum)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
prr = list(map(int,input().split()))

if n>1:
    m = sum(prr[:k])
    cur = m
    for i in range(n-k):
        cur += -prr[i] + prr[k+i]
        m = max(m,cur)

print((m+k)/2.0)