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 = [int(_) for _ in input().split()]

P = [int(_) for _ in input().split()]

for i in range(N):
    P[i] = int(P[i] * (1 + P[i]) / 2) / P[i]

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Ex = []
for p in P:
    Ex.append(0.5*(p+1))
Ex_sum = []
for i in range(N-K+1):
    e = 0
    for k in range(i,K+i):
        e += Ex[k]
    Ex_sum.append(e)
print(max(Ex_sum))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = (np.array(rl()) + 1)/2
ans = np.sum(a[:k])
for i in range(1, n-k+1):
    ans = max(ans, np.sum(a[i:i+k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = rl()
max_ = 0
for i in range(n-k+1):
  max_ = max(max_, sum(a[i:i+k]))
print((max_+k)/2)

Submission status: Time Limit Exceeded

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

(n, k), s = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split()))
print(f'{max([sum(s[i:i+k]) for i in range(n - k + 1)]):.10f}')

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))

    tmp = 0
    for i in range(n - k + 1):
        if tmp < sum(inlis[i:i+k]):
            tmp = sum(inlis[i:i+k])
            tmplis = inlis[i:i+k]
    ans = sum(map(kitaichi, tmplis))
    print(ans)



    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))

    tmp = 0
    for i in range(len(inlis)-k+1):
        if tmp < sum(inlis[i:i+k]):
            tmp = sum(inlis[i:i+k])
            tmplis = inlis[i:i+k]
    ans = sum(map(kitaichi, tmplis))
    print(ans)



    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    #print(kitalis)
    ans = 0
    for i in range(len(kitalis)-k+1):
        if ans < sum(kitalis[i:i+k]):
            ans = sum(kitalis[i:i+k])
            #print(kitalis[i:i+k])
    print(ans)



    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    ans = 0
    for i in range(len(kitalis)-k+1):
        if ans < sum(kitalis[i:i+k]):
            ans = sum(kitalis[i:i+k])
            
    print(ans)



    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(plist[i:i+K]))

print((ans + K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
  n,k=MI()
  p=LI()
  ans1 =0
  for i in range(n -k +1):
    ans2 = sum(p[i:i+k])
    if ans2 > ans1:
      ans1 = ans2
      ans_list = p[i:i+k]
  ans = sum(map(lambda i:i/2+0.5,ans_list))
  print(ans)


if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
ans1 = 0
for i in range(N -K +1):
  ans2 = sum(A[i:i+K])
  if ans2 > ans1:
    ans1 = ans2
    ans_list = A[i:i+K]
#print(ans_list)

ans = sum(map(lambda i:i/2+0.5,ans_list))


print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
ans1 = 0
for i in range(N -K +1):
  ans2 = sum(A[i:i+K])
  if ans2 > ans1:
    ans1 = ans2
    ans_list = list(A[i:i+K])
#print(ans_list)
answer = 0
for i in ans_list:
  result = sum(range(1,i+1))/i
  #print(result)
  answer += result

print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_e = 0
for i in range(N-K+1):
    max_e = max(max_e, (sum(p[i:i+K])+K)/2)
print(max_e)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[31]:


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


# In[33]:


ans = 0
for i in range(K-1,N):
#     print([(x+1)/2 for x in p[i-(K-1):i+1]])
    ans = max(ans, sum([(x+1)/2 for x in p[i-(K-1):i+1]]))
print(ans)


# In[ ]:

Submission status: Time Limit Exceeded

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

ans = [0] * n

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

print(max(ans))

Submission status: Time Limit Exceeded

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

def kitai(n):
  result = 0
  for i in range(1,n+1):
    result += i
  return result/n

s=[0]*(n+1)
for i in range(n):
  s[i+1] = s[i] + p[i]

resi = 0
tmp = 0
for i in range(n-k+1):
  if s[i+k]-s[i] > tmp:
    resi = i
    tmp = s[i+k]-s[i]

result = 0
for i in range(resi,k+resi):
  result += kitai(p[i])
print(result)

Submission status: Time Limit Exceeded

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
q=[]
for i in range(n-k+1):
    q.append(sum(p[i:k+i]))
print(max(q))

Submission status: Time Limit Exceeded

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
q=[]
for i in range(n-k+1):
    q.append(sum(p[i:k+i]))
print(max(q))

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(0, N-K+1):
    ans = max((sum(p[i:i+K])+K)/2, ans)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

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

for i in range(len(P)):
    P[i] = ( P[i] + 1 ) / 2

max = 0
for i in range(len(P)-K+1):
    add = sum(P[i:i+K])
    if add > max:
        max = add


print(max)

Submission status: Time Limit Exceeded

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

m = prev = sum(P[:k])
s = 0
for i in range(1, n - k + 1):
    tmp = prev - P[i - 1]+ P[i + k - 1]
    prev = tmp
    if tmp > m:
        s = i
    m = max(tmp, m)

ans = 0
for i in range(s, s + k):
    p = P[i]
    ans += sum(range(p + 1)) / p
print(ans)

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(sum(range(p + 1)) / p)

ans = prev = sum(e[:k])
for i in range(1, n - k + 1):
    tmp = prev - e[i - 1]+ e[i + k - 1]
    prev = tmp
    ans = max(tmp, ans)
print(ans)

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(sum(range(p + 1)) / p)

ans = 0
for i in range(n - k + 1):
    a = 0
    for j in range(i, i + k):
        a += e[j]
    ans = max(ans, a)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
P_sum = 0

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

print(ans / 2)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
from time import time

t = time()

N, K = [int(x) for x in input().split()]
line_in_dice = list([int(x) for x in input().split()])

result = [0] * (N + K)

result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]

max_point = 0
max_value = 0

for i in range(1, N):
    result[i] += (result[i - 1] + line_in_dice[i])
    result[i + K] -= line_in_dice[i]

    if result[i] > max_value:
        max_point = i
        max_value = result[i]

print(sum([median(range(1, x+1))
           for x in line_in_dice[max_point+1-K:max_point+1]]))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N, K = [int(x) for x in input().split()]
line_in_dice = list([median(range(1, int(x)+1)) for x in input().split()])

max_value = 0

for i in range(N):
    if i + K > N:
        break

    check = 0
    for x in range(K):
        check += line_in_dice[i + x]

    if check > max_value:
        max_value = check

print(max_value)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N, K = [int(x) for x in input().split()]
line_in_dice = list([int(x) for x in input().split()])

max_value = 0

for i in range(N):
    if i + K > N:
        break

    check = 0
    for x in range(K):
        check += median(range(1, line_in_dice[i + x] + 1))

    if check > max_value:
        max_value = check

print(max_value)

Submission status: Time Limit Exceeded

Solution code:
import numpy
import sys
n, k= map(int,input().split())
ps = list(map(int, input().split()))
pon=ps
i=1

if k==1:
    ans=(1+pon[pon.index(max(pon))])/2
    print(ans)
    sys.exit()

for a in range(k-1):
    ps1 = numpy.roll(pon, -i)  # = np.ndarray([ x[1], x[2], ..., x[n-1], x[0] ])
    ps = ps + ps1
    i+=1

    
if not k==1:
    num=ps.tolist().index(max(ps[:-(k-1)]))

ans=0
for a in range(k):
    ans+=(1+pon[num+a])/2
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
pList = list(map(int, input().split()))
max_sumK = 0
max_start = 0
max_end = 0
for i in range(N-K+1):
  start = i
  end = i+K
  sumK = sum(pList[start:end])
  if (sumK > max_sumK):
    max_sumK = sumK
    max_start = start
    max_end = end
answer = 0
#print("s"+str(max_start)+"g"+str(max_end))
for num in pList[max_start:max_end]:
  answer += sum(list(range(1, (num+1))))/num
print(answer)

Submission status: Time Limit Exceeded

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

max_reg = 0
for i in range(n - k + 1):
  max_reg = max(max_reg, (sum(p[i:i+k])+k)/2)
  
print(max_reg)

Submission status: Time Limit Exceeded

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

for x in p:
  q.append((x+1)/2)
  
max_reg = 0
for i in range(n - k + 1):
  max_reg = max(max_reg, sum(q[i:i+k]))
  
print(max_reg)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-06-26 21:21:26 +0900
# LastModified: 2020-06-26 21:27:41 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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




if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-06-26 20:59:48 +0900
# LastModified: 2020-06-26 21:19:42 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    expected = list(map(lambda x: (x+1)/2, p))
    e_max = 0
    for i in range(n-(k-1)):
        a = sum(expected[i:i+k])
        if e_max<a:
            e_max=a
    print(e_max)
    



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

s = []
for i in p:
  s.append((i*(i-1)/2+i)/i)

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

Submission status: Time Limit Exceeded

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

a = list(map(int,input().split()))
r_a = 0
ele = K
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N+1):
    if r_a < sum(a[i-K:i]):
        r_a = sum(a[i-K:i])
        ele = i
s_ele = ele-K
for n in range(s_ele,ele):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)

Submission status: Time Limit Exceeded

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

def expectation(N):
    exp = 0
    for i in range(1, N+1):
        exp += i/N
    return exp

Ps = []
s = 0
for p in P:
    s += p
    Ps.append(s)
    
cmax = Ps[K-1]
max_sp = 0

for ix in range(1, N-K+1):
    csum = Ps[ix+K-1] - Ps[ix-1]
    if cmax < csum:
        max_sp = ix
        cmax = csum

ans = 0
for ix in range(max_sp, max_sp+K):
    ans += expectation(P[ix])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
c=input()
d=list(c.split(' '))
for i in range(0,len(d)):
    d[i]=(1+int(d[i]))/2
A=[]
for i in range(0,a-b+1):
    e=0
    for j in range(0,b):
        e=e+d[i+j]
    A.append(e)
f=max(A)
print('%.12f'%f)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
for j in p:
    q.append((j+1) / 2)

for i in range(N-K+1):
    E = 0
    for n in range(K):
        E += q[n+i]
    if E > Etop:
        Etop = E
print(Etop)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p1=list(map(int,input().split()))
c=0
i=0
while (i+k)<=n:
  c_list=[]
  for j in range(k):
    c_list.append((p1[j+i]+1)/2)
    if sum(c_list)>c:
      c=sum(c_list)
  i+=1
print(c)

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-k+1):
    sum=0
    for j in range(i,i+k):
         sum+=p[j]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

Submission status: Time Limit Exceeded

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

# 累積和
c = [0] * (n+1)
for i in range(n):
  c[i+1] = c[i] + p[i]
#print(c)
mx = 0
mx_a = []
for i in range(n-k+1):
  t = p[i:i+k]
  st = c[i+k] - c[i]
  if st > mx:
    mx = st
    mx_a = t
ans = 0
for i in range(k):
  a = mx_a[i]
  ans += ((a * (a+1)) // 2) / a
print(ans)
# print(mx_a)

Submission status: Time Limit Exceeded

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

mx = 0
mx_a = []
for i in range(n-k+1):
  t = p[i:i+k]
  st = sum(t)
  if st > mx:
    mx = st
    mx_a = t
ans = 0
for i in range(k):
  a = mx_a[i]
  ans += ((a * (a+1)) // 2) / a
print(ans)
# print(mx_a)

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(a) for a in input().split())
p = list(map(int,input().split()))
p = list(map(lambda x : (x+1)/2 , p))
s = [0]*(N+1)
for i in range(N) :
    s[i+1] = sum(p[:i+1])

t = [0]*(N-K+1)
for j in range(N-K+1) :
    t[j] = s[j+K] - s[j]

print(max(t))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mx = sum(p[:K])
for i in range(1, N-K+1):
  mx = max(mx, sum(p[i:i+K]))
  
ans = (mx+K) / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
maxy=0
for i in range(n-k+1):
  temp=0
  for q in range(k):
    temp+=p[i+q]
  
  if temp>maxy:
    maxy=temp
    
print((maxy+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():
    n, k, *p = map(int, read().split())
    p2 = [(1 + pe) /2 for pe in p]
    r = 0
    for i1 in range(n - k + 1):
        r = max(r, sum(p2[i1:i1+k]))

    print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,K= map(int, input().split())
List = list(map(int, input().split()))
num=0
for i in range(0,N-K+1):
    a=0
    for u in range(K):
        a+=(List[i+u]+1)
    a=a/2
    if a>=num:
        num=a
print(num)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    num = 0
    for j in range(k):
        num += p[i+j]
    l.append(num)

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

Submission status: Time Limit Exceeded

Solution code:
#154D
n,k = map(int,input().split())
P = list(map(int,input().split()))

e_p  = []
for i in range(len(P)):
    e_p.append((P[i]+1)/2)

s = []
for j in (range(len(P)-k+1)):
    s.append(sum(e_p[j:j+k]))
        
print(max(s))

Submission status: Time Limit Exceeded

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

d=[]
for i in range(a-b+1):
    d.append(sum(c[i:i+b]))

n=max(d)
print((n+b)/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())))

def ave(v):
    return np.mean(np.arange(1, v + 1))

vave = np.vectorize(ave)
s = vave(p)

answer = np.sum(s[:K])
current = answer
for i in range(1, N - K + 1):
    current = current - s[i - 1] + s[i + K - 1]
    answer = max(answer, current)

print(answer)

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())))

def ave(v):
    return np.mean(np.arange(1, v + 1))

vave = np.vectorize(ave)
s = vave(p)

ans = 0
for i in range(N - K + 1):
    ans = max(ans, np.sum(s[i:i+K]))

print(ans)

Submission status: Time Limit Exceeded

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

E_P=[(1+p)/2 for p in P] 

max_ = 0
for k_ in range(len(P)-K+1):
    if max_ < sum(E_P[k_:k_+K]):
        max_=sum(E_P[k_:k_+K])
        
print(max_)

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):
    num=sum(p[i:i+k])
    if ans<num:
        ans=num
print((ans+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
num=[]
def ap(num1):
    num.append(num1)
for i in range(n):
    ap((p[i]+1)/2)
ans=[]
if k==1:
    print(max(num))
else:
    def ap2(num2):
        ans.append(num2)
    for i in range(n-k+1):
        ap2(sum(num[i:i+k]))
    print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
num=[]
def ap(num1):
    num.append(num1)
for i in range(n):
    ap((p[i]+1)/2)
ans=[]
def ap2(num2):
    ans.append(num2)
for i in range(n-k+1):
    ap2(sum(num[i:i+k]))
print(max(ans))

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):
    a = 0
    for j in range(i, i+k):
        a += (p[j]*(1+p[j]))/2/p[j]
    ans = max(ans, a)
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    tmp = sum(expect[i : i + k])
    ans = max(ans, tmp)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, kosuu = map(int, input().split(" "))
a=list(map(int, input().split(" ")))
temp = []
for i in range(n - kosuu + 1):
  temp.append(sum(a[i:i+kosuu]))
print((max(temp) + kosuu) / 2)

Submission status: Time Limit Exceeded

Solution code:
n, kosuu = map(int, input().split(" "))
a=list(map(int, input().split(" ")))
maxi = 0
for i in range(n - kosuu + 1):
  if maxi < sum(a[i:i+kosuu]):
    maxi = sum(a[i:i+kosuu])
print((maxi + kosuu) / 2)

Submission status: Time Limit Exceeded

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

max_v = 0
max_i = 0
for x in range(n - k + 1):
    s = sum([p[x+i] for i in range(k)])
    if max_v < s:
        max_v = s
        max_i = x
sums = 0.0
for x in p[max_i:max_i+k]:
    sums += (x + 1) / 2

print("{:.6f}".format(sums))

Submission status: Time Limit Exceeded

Solution code:
import copy,time

n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai = 0
kazu = [(a+1) /2 for a in m]

for x in range(int(n) - (int(k)-1)):
    kitai = kazu[x:x+int(k)]
    if ans < sum(kitai):
        ans = sum(kitai)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy,time

n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai = 0

for x in range(int(n) - (int(k)-1)):
    kazu = []
    kazu = m[x:x+int(k)]
    if ans < sum(kazu):
        ans = sum(kazu)
        kai = copy.deepcopy(kazu)

for j in range(int(k)):
    kitai += (kai[j]+1) /2

print(kitai)

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(sum(p[i:i+K]),ans)
    
print(ans/2+K/2)

Submission status: Time Limit Exceeded

Solution code:
import copy
n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai2 = 0
for x in range(int(n) - (int(k)-1)):
    kazu = []
    kazu = m[x:x+int(k)]
    if ans < sum(kazu):
        ans = sum(kazu)
        kai = copy.deepcopy(kazu)

for j in range(int(k)):
    kitai = 0
    for g in range(kai[j]):
        kitai += g+1
    kitai2 += kitai / kai[j]
print(kitai2)

Submission status: Time Limit Exceeded

Solution code:
import copy
n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai2 = 0
for x in range(int(n) - (int(k)-1)):
    kazu = []
    for l in range(int(k)):
        if x+l < len(m):
           kazu.append(m[x+l])
    if ans < sum(kazu):
        ans = sum(kazu)
        kai = copy.deepcopy(kazu)

for j in range(int(k)):
    kitai = 0
    for g in range(kai[j]):
        kitai += g+1
    kitai2 += kitai / kai[j]
print(kitai2)

Submission status: Time Limit Exceeded

Solution code:
import copy
n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kitai2 = 0
for x in range(int(n)):
    kazu = []
    for l in range(int(k)):
        if x+l < len(m):
           kazu.append(m[x+l])
    if ans < sum(kazu):
        ans = sum(kazu)
        kai = copy.deepcopy(kazu)

for j in range(int(k)):
    kitai = 0
    for g in range(kai[j]):
        kitai += g+1
    kitai2 += kitai / kai[j]
print(kitai2)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque, defaultdict

N, K = (int(i) for i in input().split())  
P = [int(i) for i in input().split()] 

dice = [0]
for i in range(1000):
  dice.append(1 + 0.5 * i)

q = deque()
ans = 0
for p in P:
  q.append(dice[p])
  
  if len(q) < K:
    continue
  else:
    ans = max(ans, sum(q))
    q.popleft()

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque, defaultdict

N, K = (int(i) for i in input().split())  
P = [int(i) for i in input().split()] 

dice = [0]
for i in range(1000):
  dice.append(1 + 0.5 * i)

q = deque()
lis = []
for p in P:
  q.append(dice[p])
  
  if len(q) < K:
    continue
  else:
    lis.append(sum(q))
    q.popleft()

print(max(lis))

Submission status: Time Limit Exceeded

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

for i in range(N):
    if P[i+K-1] == 0:
        break
    B = P[i:i+K]
    S = sum(B)
    M = max(M, S)

ans = 0.5 * (M + K)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n - k + 1):
    max_sum_k = max(max_sum_k, sum(p[i:i+k]))

max_ex = (k + max_sum_k) / 2
print(max_ex)

Submission status: Time Limit Exceeded

Solution code:

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


max_value=0
for i in range(0,n-k+1):
    max_token=0
    for j in range(0,k):
        max_token=max_token+l[i+j]
        if max_value<max_token:
            max_value=max_token
            

print((max_value+k)/2)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

ans = 0
q = collections.deque()
for i in range(n):
    tmp = (1+a[i])/2
    q.append(tmp)
    if len(q) > k:
        q.popleft()
    ans = max(ans,sum(q))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0

    for i in range(n - k + 1):
        ref = sum(p[i: i + k])
        if ref > ans:
            ans = ref

    print(ans/2 + k*0.5)

main()

Submission status: Time Limit Exceeded

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

for i in range(0, N-K+1):
    e = 0
    if i > 0:
        if P[i-1] >= P[i+K-1]:
            continue
    for j in range(i, i+K):
        e += (P[j] + 1) / 2
    max_e = max(e, max_e)

print(max_e)

Submission status: Time Limit Exceeded

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

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0

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

    print(ans)

main()

Submission status: Time Limit Exceeded

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

for i in range(0, N-K+1):
    e = 0
    for j in range(i, i+K):
        e += (P[j] + 1) / 2
    max_e = max(e, max_e)

print(max_e)

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):
    ref = sum(p[i: i + k])/2 + k*0.5
    if ref > ans:
        ans = ref

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
# S=list(map(int,input().split()))
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

ans=0

for i in range(len(S)):
    try:
        t=S[i]-S[i+K]
    except IndexError:
        t=0
    if t<0:
        pass
    else:
        temp=sum(S[i:i+K])
        if ans<temp:
            ans=temp
        else:
            pass
print(ans)