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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(E[i] + SUM / p)
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k,*p=map(int,open(0).read().split())
l=[]
for i in range(n-k+1):
  sums=[]
  for j in p[i:i+k]:
    sums.append(j*(j+1)/(2*j))
  l.append(sum(sums))
print(max(l))

Submission status: Time Limit Exceeded

Solution code:
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = []
for i in range(N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(SUM/p)
l = 0
r = K - 1
ans = 0
while r < N:
    ans = max(ans, sum(E[l:r+1]))
    l += 1
    r += 1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(len(q)):
    ans = max(ans, sum(q[i:i+k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))

q = np.zeros_like(p, dtype='float')
for i in range(n):
    q[i] += (1+p[i]) / 2.0

ans = 0
for i in range(n):
    ans = max(ans, sum(q[i:i+k]))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
lis = list(map(int,input().split()))
E = [(n+1)/2 for n in lis]
E_lis = [sum(E[num:num+K]) for num in range(N-K+1)]
print(max(E_lis))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = [int(i) for i in input().split()]
maxP = 0

for i in range(N-K+1):
    a = sum(P[i:i+K])
    if maxP < a:
        maxP, array = a, P[i:i+K]
print(sum([i*(i+1)/2/i for i in array]))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
lis = list(map(int,input().split()))
E=[]
E_lis=[]
for n in lis:
  E.append((n+1)/2)
for num in range(N-K+1):
  E_lis.append(sum(E[num:num+K]))
print(max(E_lis))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
lis = list(map(int,input().split()))
E=[]
for num in range(N-K+1):
  sum=0
  X=lis[num:num+K]
  for x in X:
    sum+= (x+1)/2
  E.append(sum)
print(max(E))

Submission status: Time Limit Exceeded

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

s = 0
for i in range(n-k+1):
    a = sum(p[i:i+k])
    if a > s:
        s = a
        
print((s+k)/2)

Submission status: Time Limit Exceeded

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

maxNum = -1

for indx in range(N - (K - 1)):
  maxNum = max(sum(inList[indx: indx + K]), maxNum)

print((maxNum + K) / 2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K= map(int, input().split())
p = np.array(list(map(int, input().split())))

max = 0
j = N-K+1
for i in range(j):
    tmp = np.sum(p[i:i+K])
    if tmp>max:
        max = tmp

print((max+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


N, K= map(int, input().split())
p = np.array(list(map(int, input().split())))

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

print((max+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


N, K= np.array(list(map(int, input().split())))
p = np.array(list(map(int, input().split())))

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

print((max+K)/2)

Submission status: Time Limit Exceeded

Solution code:
def all_sum(val):
    sum = 0
    for i in range(val):
        sum = sum + i + 1
    return sum / val


[n, k] = input().split()

p = input().split()

k = int(k)
n = int(n)
p = [int(i) for i in p]

total = 0
max_total = 0
for i in range(k):
    total = total + p[i]
max_total = total
max_ind = 0

for i in range(n - k):
    total = total - p[i] + p[i + k]
    if(max_total < total):
        max_total = total
        max_ind = i + 1
ans = 0
for i in range(k):
    ans = ans + all_sum(p[i + max_ind])

print("{:.8f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
#面の数から期待値に変換してからforぶん回して無理やり最大値を求める
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
sumOfValue = 0
#サイコロの目を期待値に変換
for eyes in dices:
    expected.append((eyes+1)/2)
#最大値を求める
for maxvalue in range(len(expected)-k+1):
    sumOfValue = sum(expected[maxvalue:maxvalue+k])
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Time Limit Exceeded

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

p = list(map(int,input().split()))
s = []
for i in range(n-k+1):
    s += [sum(p[i:i+k])]
t = max(s)
print((t + k)/2)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = {}
maxn = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        if not p[i+j] in kita.keys():
            kita[p[i+j]] = 0.5*(p[i+j]+1)
        kt += kita[p[i+j]]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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(t[i+j])
    if max<x :
        max=x
print((max+K)/2)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = [0.5*(i+1) for i in range(max(p)+1)]
maxn = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kita[p[i+j]]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
max=0
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: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = [0.5*(i+1) for i in range(max(p)+1)]
kitai = [kita[i] for i in p]
maxn = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kita[p[i+j]]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = [0.5*(i+1) for i in range(max(p)+1)]
kitai = [kita[i] for i in p]
maxn = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kitai[i+j]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
'''
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]

shi = []
for i in range(max(p)):
    if i == 0:
        shi.append(1)
    else:
        shi.append(i+1+shi[i-1])

kitai = [shi[i]/(i+1) for i in range(len(shi))]

max = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kitai[p[i+j]-1]
    if kt > max:
        max = kt
print("{:.12f}".format(float(max)))
'''

n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kitai = [0.5*(i+1) for i in p]
maxn = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kitai[i+j]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]

shi = []
for i in range(max(p)):
    if i == 0:
        shi.append(1)
    else:
        shi.append(i+1+shi[i-1])

kitai = [shi[i]/(i+1) for i in range(len(shi))]

max = 0
for i in range(n-k+1):
    kt = 0
    for j in range(k):
        kt += kitai[p[i+j]-1]
    if kt > max:
        max = kt
print("{:.12f}".format(float(max)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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):
  s = sum(p[i:(i+k)])
  if max < s:
    max = s
    
print((max+k)/2.0)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ans = 0
total = 0
for i in range(N - K + 1):
    total = 0
    c = 1
    for k in range(i, i + K):
        total += (p[k] * (p[k] + 1) / 2) * c * np.prod(p[k + 1: i + K])
        c *= p[k]
    ans = max(total / c, ans)
print(ans)

Submission status: Time Limit Exceeded

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 _ in range(k):
    s += p[j]
    j += 1
  if max < s:
    max = s
    
print((max+k)/2.0)

Submission status: Time Limit Exceeded

Solution code:
a,b = input().split()
a = int(a)
b = int(b)
c = list(map(int,input().split()))

nx = 0
for i in range(a-b+1):
  x = 0
  for j in range(b):
  	x += (c[i+j]+1) / 2
  nx = max(nx,x) 

print('{:.12f}'.format(nx))

Submission status: Time Limit Exceeded

Solution code:
a,b = input().split()
a = int(a)
b = int(b)
x = [0]*(a+1)

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

for i in range(a-b+1):
  for j in range(b):
  	x[i] += (c[i+j]+1) / 2

print('{:.12f}'.format(max(x)))

Submission status: Time Limit Exceeded

Solution code:
import sys
def main():
    l= sys.stdin.readline()
    N, K = list(map(int, l.split()))
    l = sys.stdin.readline()
    nums = list(map(lambda a:(int(a)+1)/2.0, l.split()))
    
    M = [sum(nums[:K])]
    for i in range(K, len(nums)):
        M.append(max(M[-1], sum(nums[i-K+1:i+1])))
    return M[-1]
if __name__ == "__main__":
    print(main())

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split(' ')]
E = [(int(x) + 1) / 2 for x in input().split(' ')]
S = [sum(E[i:i+K]) for i in range(N-K+1)]
print(max(S))

Submission status: Time Limit Exceeded

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

p = list(map(int,input().split()))
s = []
for i in range(n-k+1):
    t = sum(p[i:i+k])
    s += [((t+k)/2)]
print(max(s))

Submission status: Time Limit Exceeded

Solution code:
n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
  score = 0 
  for j in range(k):
    n = seq[i+j]
    score += 1/2*(2+(n-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))

Submission status: Time Limit Exceeded

Solution code:
r=input().strip().split()
N=int(r[0])
a=int(r[1])
z=input().strip().split()

maximum=0

for j in range (0,N-a+1):
  s=0
  for p in range (j,j+a):
    s+=(1+int(z[p]))/2
 
  if s>maximum:
    maximum=s

print(maximum)

Submission status: Time Limit Exceeded

Solution code:
r=input().strip().split()
N=int(r[0])
a=int(r[1])
z=input().strip().split()
w=[]
for i in range (N):
  w.append((1+int(z[i]))/2)

maximum=0

for j in range (0,N-a+1):
  s=0
  for p in range (j,j+a):
    s+=w[p]
 
  if s>maximum:
    maximum=s

print(maximum)

Submission status: Time Limit Exceeded

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

ave = [(p[i]+1)/2 for i in range(N)]

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans0 = 0
for i in range(n-k+1):
    P = sum(p[i:i+k])
    if ans0 <= P:
        ans0 = P
        ans = (ans0+k*1)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# numpy使うときは、PyPyは不可
import numpy as np

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

ans = 0

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

print(float(ans/2))



# 回答
# Pcum = np.zeros(N + 1, np.int32)
# Pcum[1:] = P.cumsum()
#
# length_K_sums = Pcum[K:] - Pcum[0:-K]
# print(length_K_sums.max() / 2)

Submission status: Time Limit Exceeded

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


m=0
ml=[]
if(K!=1):
    for i in range(N-K+1):
        tmp=0
        tmpl=[]
        for j in range(i,K+i):
            tmp+=p[j]
            tmpl.append(p[j])
        if(tmp > m):
            m=tmp
            ml=tmpl
else:
    ml=[max(p)]
kitai=0
for pi in ml:
    for i in range(1,pi+1):
        kitai+=i/pi

print(kitai)

Submission status: Time Limit Exceeded

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

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

dices = p[:k]

def exp(n):
    return n*0.5 + 0.5

def exp_list(l):
    total = 0
    for n in l:
        total += exp(n)
    return total

ans = exp_list(dices)

for i in range(1,n-k+1):
    del dices[0]

    dices.append(p[i+k-1])

    tmp = exp_list(dices)

    if tmp > ans:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

sum_K = [sum(nums[i:i+K]) \
        for i in range(len(nums)-K+1)]
        
print((max(sum_K)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))

INDEX = -1
MA = 0
for i in range((N - K + 1)//2):
    M = 0
    L = 0
    for j in range(K):
        M += P[i + j]
        L += P[-1-i-j]
    # print(L)
    if M > MA:
        MA = M
        INDEX = i
    if L > MA:
        MA = L
        INDEX = N-K-i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))

INDEX = -1
MA = 0
for i in range(N - K + 1):
    M = 0
    for j in range(K):
        M += P[i + j]
    
    if M > MA:
        MA = M
        INDEX = i
# print(i)
ans = 0
for i in range(K):
    # print(P[i+INDEX])
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])
    # print(M)
    # print(i)
# print(tmp)
# ans = 0
# for t in tmp:
#     ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))

tmp = []
MA = 0
for i in range(N - K + 1):
    M = 0
    t = []
    for j in range(K):
        M += P[i + j]
        t.append(P[i + j])
    
    if M > MA:
        tmp = t
        MA = M



    # print(M)
    # print(i)
# print(tmp)
ans = 0
for t in tmp:
    ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
# 自分の
N, K = map(int, input().split())
p_arr = list(map(int, input().split()))

# 最高値を算出
max_sum = 0
for i in range(N-K+1):
    if sum(p_arr[i:i+K])>max_sum:
        max_sum = sum(p_arr[i:i+K])

answer = (max_sum + K) / 2
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))

tmp = []
MA = 0
for i in range(N - K + 1):
    M = 0
    t = []
    for j in range(K):
        M += P[i + j]
        t.append(P[i + j])
    
    if M > MA:
        tmp = t
        MA = M
    # elif M == MA:
    #     tmp.append(t)
    #     MA = M


    # print(M)
    # print(i)
# print(tmp)
ans = 0
for t in tmp:
    ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
def exp_sum(n:int, k:int, P:list):
    each_sum = []
    mx, total, x = 0, 0, 0
    for i in range(k - 1, n + 1):
        total = exp_val_sum(P[:i])
        total = total - exp_val_sum(P[:(i - k + 1)]) + (P[i - k] + 1) / 2
        each_sum.append(total)
        total = 0

    return max(each_sum)

def exp_val_sum(X:list):
    total = (sum(X) + len(X)) / 2
    return total

def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 0
    print(exp_sum(n, k, P))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def exp_sum(n:int, k:int, P:list):
    each_sum = []
    mx, total, x = 0, 0, 0
    for i in range(k - 1, n + 1):
        total = exp_val_sum(P[:i])
        total = total - exp_val_sum(P[:(i - k + 1)]) + (P[i - k] + 1) / 2
        each_sum.append(total)
        total = 0

    return max(each_sum)

def exp_val_sum(X:list):
    total = 0
    for i in range(len(X)):
        total += (X[i] + 1) / 2
    return total

def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 0
    print(exp_sum(n, k, P))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=[(i+1)/2 for i in P]
M=0
for i in range(len(P)-K+1):
    if sum(P[i:i+K])>M:
        M=sum(P[i:i+K])
print(M)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split(" "))
p_list=list(map(int,input().split(" ")))
def expect(i):
    return 0.5*(p_list[i]+1)

e_list=[expect(i) for i in range(N)]

expect_list=[sum(e_list[i:K+i]) for i in range(0,N-K+1+1)]

print(max(expect_list))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = [0.0] * n
for i in range(n):
    e[i] = (1 + p[i]) * 0.5
s = 0.0
for i in range(k, n + 1):
    t = sum(e[i - k:i])
    if s < t:
        s = t
print(s)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = [0.0] * n
for i in range(n):
    e[i] = (1 + p[i]) * 0.5
s = 0.0
for i in range(k, n + 1):
    s = max(s, sum(e[i - k:i]))
print(s)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = [0.0] * n
for i in range(n):
    e[i] = (1 + p[i]) * 0.5
s = [0.0] * (n - k + 1)
for i in range(n - k + 1):
    for j in range(k):
        s[i] += e[i + j]
print(max(s))

Submission status: Time Limit Exceeded

Solution code:
N=[int(e) for e in input().split()]
p=[(int(e)+1)/2.0 for e in input().split()]
p2=[0.]*(N[0]-N[1]+1)
for i in range(N[0]-N[1]+1):
    p2[i]=sum(p[i:(i+N[1])])

print(max(p2))

Submission status: Time Limit Exceeded

Solution code:
N=[int(e) for e in input().split()]
p=[int(e) for e in input().split()]
p2=[0]*(N[0]-N[1]+1)
for i in range(N[0]-N[1]+1):
    a=0
    for j in range(N[1]):
        a=a+(p[i+j]+1)
    p2[i]=a

print(max(p2)/2.)

Submission status: Time Limit Exceeded

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

print(max(p2))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=[int(e) for e in input().split()]
p=[int(e) for e in input().split()]
p2=[0.]*(N[0]-N[1]+1)
for i in range(N[0]-N[1]+1):
    for j in range(N[1]):
        p2[i]=p2[i]+(p[i+j]+1)/2

print(max(p2))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def start_point(n, k, P):
    mx, total, x = 0, 0, 0
    for i in range(n - k + 1):
        for j in range(i, i + k):
            total += expected_value(P[j])
        mx = max(mx, total)
        if mx == total:
            x = i
        total = 0
    return x

def expected_value(p):
    value = 0
    for i in range(p + 1):
        value += i
    return value / p

def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 0
    start = start_point(n, k, P)
    for i in range(start, start + k):
        ans += expected_value(P[i])
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
ans = 0.0
SS = {sum(B[i:i+A[1]]):B[i:i+A[1]] for i in range(len(B)-A[1]+1)}
kitaiti = {i : (i+1)/2 for i in range(1,1001)}
for i in SS[max(SS)]:
    ans += kitaiti[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
ans = 0.0
SS = {sum(B[i:i+A[1]]):B[i:i+A[1]] for i in range(len(B)-A[1]+1)}
for i in SS[max(SS)]:
     ans += (i/2*(i+1))/i
print(ans)

Submission status: Time Limit Exceeded

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+1))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = []
s = [0]
sj = []

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(sum(e[:x + 1]))

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
P = [(int(x) + 1) / 2 for x in input().split()]
l = [sum(P[i:(i+K)]) for i in range(N - K +1)]
print('{:.12f}'.format(max(l))) #小数点以下12桁まで指定

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
P = [(int(x) + 1) / 2 for x in input().split()]
l = []
for i in range(N - K + 1):
    l.append(sum(P[i:(i+K)]))
print('{:.12f}'.format(max(l))) #小数点以下12桁まで指定

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def exp_val(n):
    return (n+1)/2

def dice_in_line():
    K,N=map(int,input().split())
    p_n=list(map(int,input().split()))
    exp=[]
    for i in p_n:
        exp.append(exp_val(i))
    exp_sum=[]
    for i in range(K-N+1):
        exp_sum.append(sum(exp[i:i+N]))
    print(max(exp_sum))

dice_in_line()

Submission status: Time Limit Exceeded

Solution code:
import numpy

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

def expectation_cal(dice_side):
	ans = numpy.arange(1, dice_side+1, 1, dtype=int)
	ans = numpy.sum(ans*(1/dice_side))
	return(ans)


def max_sum_find(num_list, n, k):
	loop = range(n-k+1)
	max_sum=0
	for i in loop:
		if max_sum < sum(num_list[i:i+k]):
			max_sum = sum(num_list[i:i+k])
	return(max_sum)


expectations = list(map(expectation_cal, p))
print(max_sum_find(expectations, n, k))

Submission status: Time Limit Exceeded

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

a = []
ans = []
for i in range(len(p)):
  a.append((p[i]+1)/2)
for i in range(N-K+1):
  temp = 0
  for j in range(K):
    temp += a[i+j]
  ans.append(temp)
  
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
p_seq = np.array(list(map(int, input().split())))
print(max(sum((p_seq[i:i+k] + 1) / 2) for i in range(n - k + 1)))

Submission status: Time Limit Exceeded

Solution code:
N, K = (int(i) for i in input().split())
p = [int(i) for i in input().split()]
sum_max = 0
sum_max_index = 0
for i in range(N-K+2):
  #print(i)
  tmp_sum = sum(p[i:i+K])
  #print(sum_max)
  if sum_max < tmp_sum:
    sum_max = tmp_sum
    sum_max_index = i
total_num = 0
for i in range(sum_max_index,sum_max_index+K):
  total_num += (p[i]+1)/2
print(total_num)

Submission status: Time Limit Exceeded

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

max = 0
for i in range(N-K+1):
  temp = 0
  for j in range(i,i+K):
    temp += l[j]
  if temp > max:
    max = temp

print((max+K)/2)

Submission status: Time Limit Exceeded

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

E = []
for p in P:
  E.append((p+1)*p/2/p)
mx = 0
for i in range(N-K+1):
  mx = max(sum(E[i:i+K]),mx)
print(mx)

Submission status: Time Limit Exceeded

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

for i in range(n):
    c = sum(p[i:i+k])
    if c > Max:
        Max = c
        ind = i

for i in range(ind,ind+k):
    ans += (p[i] + 1) / 2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def sigma(p):
    return sum([i for i in range(p,0,-1)]) / p

n,k = map(int,input().split())
p = list(map(int,input().split()))
Max = 0
ans = 0

for i in range(n):
    c = sum(p[i:i+k])
    if c > Max:
        Max = c
        ind = i

for i in range(ind,ind+k):
    ans += sigma(p[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def sigma(p):
    return sum([i for i in range(p,0,-1)]) / p

n,k = map(int,input().split())
p = list(map(int,input().split()))
Max = 0
ans = 0

for i in range(n):
    if sum(p[i:i+k]) > Max:
        Max = sum(p[i:i+k])
        ind = i

for i in range(ind,ind+k):
    ans += sigma(p[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
input_line = input()
N_K = [int(x) for x in input_line.split()]
N = N_K[0]
K = N_K[1]

input_line = input()
p = [int(x) for x in input_line.split()]

def expected_value(p_i:int):
    value = [x for x in range(1, p_i+1)]
    ret = 0
    for i in value:
        ret += i / p_i
    return ret

def calc_sum(x:int, vals:list):
    temp = 0
    for i in range(K):
        temp += vals[x+i]
    return temp

max_val = 0
exp = [expected_value(x) for x in p]

for i in range(N-K+1):
    temp = calc_sum(i, exp)
    if temp > max_val:
        max_val = temp
print(max_val)

Submission status: Time Limit Exceeded

Solution code:
kitailist = []
NandK = input()
pi = input()
NandK = NandK.split(' ')
pi = pi.split(' ')
K = int(NandK[1])
for j in range(len(pi)-K+1):
    kitaiti = 0
    for num in range (0,K):
        kitaiti = kitaiti + (((int(pi[j + num]))+1)/2)
    kitailist.append(kitaiti)
print(max(kitailist))

Submission status: Time Limit Exceeded

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

for x in range(n - k + 1):
    c = 0
    for y in range(k):
        c += p[x + y]
    p2.append(c)

a = max(p2)

print((a + k)/2)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
max = 0
d = 0
e = 0

for x in range(n - k + 1):
    c = 0
    for y in range(k):
            c += p[x + y]
    if c > max:
        max = c
        d = x

for x in range(k):
    e += (p[d + x] + 1) / 2

print(e)

Submission status: Time Limit Exceeded

Solution code:
def exp_val(n):
    return (n+1)/2

def dice_in_line():
    K,N=map(int,input().split())
    p_n=list(map(int,input().split()))
    exp=[]
    for i in p_n:
        exp.append(exp_val(int(i)))
    exp_sum=[]
    for i in range(K-N+1):
        exp_sum.append(sum(exp[i:i+N]))
    print(max(exp_sum))

dice_in_line()

Submission status: Time Limit Exceeded

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

a = 0
b = 0
c = 0
v = 0
w = 0
for i in range(n - k + 1):
    v = 0
    for j in range(i, i + k):
        v += p[j]
    if v > w:
        w = v
w += k
w /= 2
print(w)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 3
1 2 2 4 5
'''

def solve(l,k):
	n = len(l)
	subs = []
	for i in range(n-k+1):
		subs.append(l[i:i+k])
	maxx = -1
	sub = []
	for i in subs:
		summ = sum(i)
		if(summ > maxx):
			maxx = summ
			sub = i
	ans = 0
	for i in sub:
		curr = i*(i+1)/2
		ans += curr/i
	# print(subs)
	return ans
	

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print("%.10f"%ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

kernel = [1] * K
est = (p + 1) / 2

est_k = np.convolve(est, kernel)
print(np.max(est_k))

Submission status: Time Limit Exceeded

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