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:
import itertools

n, k = map(int, input().split(" "))
p_list = list(map(int, input().split(" ")))
max_num = 0
ans = 0

m = p_list.index(max(p_list))
"""
for i in range(m-k,m+k,1):
    sum_list = sum(p_list[i:i+k])
    if max_num < sum_list:
        max_num = sum_list
        ans_list = p_list[i:i+k]

"""

for i in range(n-(k-1)):
    sum_list = sum(p_list[i:i+k])
    if max_num < sum_list:
        max_num = sum_list
        ans_list = p_list[i:i+k]


for i in range(k):
    ans = ans + sum(range(ans_list[i]+1))/ans_list[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
from itertools import accumulate
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
E = [0]*N

for i in range(N):
  E[i] = (p[i]+1)/2
  
#acc = list(accumulate(E))
#print(E,acc)

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(0.5*(sum(p[i:i+k])+k))
print("{:.6f}".format(max(lstp)))

Submission status: Time Limit Exceeded

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

maxList = []
maxList_sum = 0
kitaichi = 0
for index in range(len(p)):
  list_p = p[index:index+K]
  if sum(list_p) > maxList_sum:
    maxList = list_p
    maxList_sum = sum(maxList)

for item in range(len(maxList)):
  number = maxList[item]
  s = sum(list(range(number+1)))
  kitaichi += s / number

print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,P = input().split()
N = int(N)
P = int(P)
p = [int(e) for e in input().split()]
result = []
for i in range(len(p)):
    result.append((np.arange(p[i])+1).sum()/p[i])
max_sum = 0
for i in range(len(result)-P+1):
    res_sum = 0
    for j in range(P):
        res_sum = res_sum + result[i+j]
    if res_sum > max_sum:
        max_sum = res_sum
print('{:.12f}'.format(max_sum))

Submission status: Time Limit Exceeded

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

a = [(1+p[i])/2 for i in range(n)]
res = sum(a[0:k])

for i in range(k,n):
    if a[i-k]<a[i]:
        if sum(a[i-k+1:i+1])>res:
            res = sum(a[i-k+1:i+1])


print(res)

Submission status: Time Limit Exceeded

Solution code:

import statistics


if __name__ == "__main__":
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    P_ave = []
    max = 0
    for i in P:
        ls = list(range(1, i + 1, 1))
        i_ave = statistics.mean(ls)
        P_ave.append(i_ave)
    for j in range(len(P_ave)):
        hoge = sum(P_ave[j : j+K])
        if max <= hoge:
            max = hoge
    ret = max
    print(ret)

Submission status: Time Limit Exceeded

Solution code:

N,K = map(int,input().split())
P_List=list(map(int,input().split()))
#print(N,K)
#print(P_List)

def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    #print(p,result)
    return result

kitaichi_list=[]
for a in range(N):
    kitaichi_list.append(Kitaichi(P_List[a]))

#print(kitaichi_list)

pre_max=0
temp_max=0
max_num=0
for j in range(N-(K-1)):
    for k in range(K):
        #temp_max += P_List[j+k]
        #temp_max += Kitaichi(P_List[j+k])
        temp_max += kitaichi_list[j+k]
    #print(temp_max)

    if pre_max < temp_max:
        pre_max = temp_max
        max_num = j
    temp_max=0

#print('max_num:',max_num)
#result = 0
#for l in range(K):
#    result += Kitaichi(P_List[max_num+l])

#print(result)
print(pre_max)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
List = list(map(int,input().split()))
result = [(1+i)/2 for i in List]
Answer = 0
for i in range(N-K+1):
  counter = sum(result[i:i+K])
  if counter > Answer:
    Answer = counter

print(Answer)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
#print(N,K)
start = 0
stop = K
Max = 0
P = input().split()
#print(P)
while N >= stop:
  part = P[start:stop]
  tempMax = sum(int(i) for i in part)
#  print(tempMax)
  if tempMax > Max:
    Max = tempMax
    partMax = part
  start = start + 1
  stop = stop + 1
#print(Max)
#print(partMax)

sumMax = []

for i in partMax:
  sump = sum(p+1 for p in range(int(i)))
  #print(sump)
  sumMax.append(sump/int(i))
print(sum(sumMax))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

x = input().split()
n = int(x[0])
k = int(x[1])

p = input().split()
p = np.array(list(map(int,p)))
q = p/2

e_max = 0
for i in range(n-k+1):
  e = 0
  for j in range(k):
    e += q[i+j] + 0.5
  if e_max < e:
    e_max = e

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

Submission status: Time Limit Exceeded

Solution code:
def calc(n):
  return (n+1)/2.0

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

cnt=0.0
for i in range(N-K+1):
  S=sum(Q[i:i+K])
  cnt=max(cnt,S)

print(cnt)

Submission status: Time Limit Exceeded

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

tmp = 0

for i in range(0, N - K + 1):
  max_value = 0
  for j in range(K):
    max_value += (P[i+j]+1)/2
  if max_value >= tmp: 
    tmp = max_value

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

exps = []
ans = []

for ii in range(N):  
  p[ii] = int(p[ii])
  e = np.arange(1,p[ii]+1)
  exps.append(np.sum(e)/p[ii])

for ii in range(K-1,N):
  ans.append(np.sum(exps[ii-K+1:ii+1]))
    

print(np.max(ans))

Submission status: Time Limit Exceeded

Solution code:

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

tmp = 0
ans = []
for i in range(K, N + 1, 1):
    for j in range(i - K, i, 1):
        tmp += (P[j] * (P[j] + 1) / 2 / P[j])
    ans.append(tmp)
    tmp -= tmp

print(max(ans))

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):
    tmp = p[i]
    # print("i:" + str(i))
    for j in range(i+1,i+K):
        tmp += p[j]

    # print(tmp)
    if(max < tmp):
        max = tmp 
        maxStartIndex = i
ans = 0
for i in range(maxStartIndex, maxStartIndex+K):
    sum = p[i] * (p[i]+1) / 2
    ans += sum/p[i]
print('{:.12f}'.format(ans))
# 1 2 3 
# 3 2 1


# n, n-1, n-2
# n(n + 1)/2

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = map(int, input().split())
    dice_num = list(map(int, input().split()))
    result = 0

    for i in range(n - k + 1):
        tmp = 0
        for j in range(k):
            for l in range(1, dice_num[i + j] + 1):
                tmp += l * 1 / dice_num[i + j]

        if result < tmp:
            result = tmp

    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

kitaichi = [(v/2*(v+1))/v for v in c]

score = [sum(kitaichi[i:i+k]) for i,v in enumerate(kitaichi) if i+k-1 != len(kitaichi)]
print(max(score))

Submission status: Time Limit Exceeded

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

  def CalExVal(x):
      return (1/2*(x+1))
  #Ex = list((map(CalExVal, A)))
  temp = len(A)-K + 1
  #adjlist = [0]*(temp)
  adjlist = [sum(list(map(CalExVal, A))[i:(K+i)]) for i in range(temp)]
  #for i in range(temp):
  #    adjlist[i] = sum(Ex[i:(K+i)])

  print(max(adjlist))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
l = list(map(int,input().split()))
 
def E(n):
  return sum(range(1,n+1)) / n
 
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
elif N == K:
  l2 = list(map(E, l))  
  print(sum(l2))
elif K == 1:
  print(E(max(l)))
else:
  j = sum(l[0:0+K])
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))
 
  print(sum(l2))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    N,K = map(int, input().split())
    p = np.array(list(map(int,input().split())))
    p = (p+1)/2
    ans = 0.0
    for i in range(N-K+1):
        buf = sum(p[i:i+K])
        if ans < buf:
            ans = buf
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
for i in range(N-K+1):
  p = P[i:i+K]
  sum_ = (sum(p)+K)/2
  if i == 0:
    ans = sum_
  else:
    if sum_ > ans:
      ans = sum_
    else:
      continue
print(ans)

Submission status: Time Limit Exceeded

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

list_ans = 0

for i in range(n-k+1):
    list_sum = list_score[i:i+k]
    if sum(list_sum) >= list_ans:
        list_ans = sum(list_sum)




ans = list_ans*0.5 + 0.5*k

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

ans = []

#for i in range(n-k+1):
#    ans.append((a_np[i:i+k].sum()+k)/2)
#[式 for 任意の変数名 in イテラブルオブジェクト]
[ans.append((a_np[i:i+k].sum()+k)/2) for i in range(n-k+1)] 
print(max(ans))

Submission status: Time Limit Exceeded

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



a=N-K+1
s=[0]*a
for i in range(a):
    s[i]=np.sum(p[i:(i+K)])
k=max(s)
print((k+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)

E = 0
for dice in dices:
    E -= expectations.popleft()
    e = sum(range(1, dice + 1)) / dice
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)

Submission status: Time Limit Exceeded

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

max_prod = 0
l=[]
for i in range(a[0] - a[1] + 1):
    chunk = b[i:i + a[1]]  # i, i + 1, ..., i + 12 番目の13個の数字を取り出す。
    prod = sum(chunk)# 部分リストのすべての値の和
    if prod>max_prod:
        l=chunk
    max_prod = max(max_prod, prod)  # 最大値更新

ans=0
for i in range(len(l)):
    ans+=(l[i]+1)/2
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
def main():
    N,K = list(map(int, input().split()))
    p = list(map(int, input().split()))
    n = N-K+1
    kitai = [None] * n
    for i in range(N-K+1):
        kitai[i] = ((sum((p[i:i+K]))+K)*0.5)
    print('{:.12f}'.format(max(kitai)))
main()

Submission status: Time Limit Exceeded

Solution code:
NK = [int(i) for i in input().split(" ")]
list1 = [(int(i)+1)/2 for i in input().split(" ")]
list2 = []
for j in range(NK[0]-NK[1]+1):
    list2.append(sum(list1[j:j+NK[1]]))
        
print(max(list2))

Submission status: Time Limit Exceeded

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

wa_max =0

for i in range(0, N-K+1):
  wa = sum(s[i:i+K])
  if wa>wa_max:
    max_numbers = list(s[i:i+K])
    wa_max = wa

wa_kitai = 0

for v in max_numbers:
  wa_kitai += sum(list(range(int(v)+1)))/int(v)
print(wa_kitai)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

def main():
    N, K = map(int, input().split())
    p = list(map(float, input().split()))

    p = np.array(p)
    p_prime = p
    p_1 = p + 1
    p = p * p_1 / 2
    p = p / p_prime
    k = p
    for i in range(K-1):
        k = k + np.roll(p, i+1)

    print(max(k))


    return 0

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N-K+1):
  A = P[i:i+K]
  total = sum(A)
  if i==0:
    B = A
  elif sum(B)<total:
    B = A
np.array(B)
C = (B+np.array([1]))/np.array([2])
print(sum(C))

Submission status: Time Limit Exceeded

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

limit_sum = sum(sorted(p_list, reverse=True)[:3])

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        now_sum += p_list[p_i + i]

    if limit_sum == now_sum:
        max_sum = now_sum
        scope_index = p_i
        break

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = []
for i in range(k):
    max_scope_list.append(p_list[scope_index + i])

ex = 0
for scope in max_scope_list:
    for num in range(1, scope+1):
        ex += num*1/scope
print(ex)

Submission status: Time Limit Exceeded

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


maxnum=0
index=0
num=0
for i in range(len(P)):
    num+=P[i]



    if maxnum<num:
        maxnum=num
        index=i




    if i>=K-1:
        num-=P[i-(K-1)]


List=[]
for i in range(K):
    x1=P[index-i]
    sumx1=0
    for j in range(1,x1+1):
        sumx1+=j

    sumx1=sumx1/x1
    List.append(sumx1)


print(sum(List))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=[int(_) for _ in input().split()]
for i in range(n):
  p[i]=float(sum(range(1,p[i]+1))/p[i])
ans=0
for i in range(n-k+1): 
  tmp=sum(p[i:i+k])
  if ans<=tmp:
    ans=tmp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def max_kitai_calc(n,k,data):
    max_value = 0
    for x in range(n-k+1):
        current_value = sum([(1+x)/2 for x in data[x:x+k]])
        if max_value < current_value:
            max_value = current_value

    return max_value

[n,k] = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]

max_kitai = max_kitai_calc(n,k,data)

print(max_kitai)

Submission status: Time Limit Exceeded

Solution code:
import array

def expect_value(number):
  expect = 0
  for i in range(1, number+1):
    expect = expect + i / number
  return expect
  
N, K = map(int, input().split())
num = list(map(int, input().split()))

# 各サイコロの期待値を出す
expect = array.array('f')
for i in range(N):
  expect.append(expect_value(num[i]))

# 隣接するN個の期待値を出す
max = 0
for i in range(N):
  if i > N - K:
    break
  temp = 0
  for j in range(K):
	  temp = temp + expect[i + j]
  if max < temp:
    max = temp
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):
    n = 0
    for j in range(K):
        n += 1/2.0*(P[i+j]+1)
    if ans < n:
        ans = n

print(ans)

Submission status: Time Limit Exceeded

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

sum_l = 0
sum = 0
sum_p = 0
sum_p_len = []
max = 0

for i in range(len(p) - K + 1):
    l = p[i:K]
    for j in l:
        sum_l += j
    if max < sum_l:
        max = sum_l
        sum_p_len = l
    sum_l = 0
    K += 1

# print(sum_p_len)

for i in sum_p_len:
    for j in range(i):
        j += 1
        sum += j / i
    sum_p += sum
    sum = 0

print(sum_p)

Submission status: Time Limit Exceeded

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

n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

Submission status: Time Limit Exceeded

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

e = []

for i in range(len(p)):
  e_val = 0
  for j in range(1, p[i] + 1):
    e_val = e_val + (j / p[i])
  e.append(e_val)

tmp = 0
l = 0

while True:
  res = 0
  j = 0
  for j in range(k):
    res = res + e[l + j]
  if tmp < res:
    tmp = res
  l = l + 1
  if l + k > len(e):
    break

print(tmp)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = [0.0] * 10000

rmax = -1
pos = -1
for i in range(n-k+1):
    _t = sum(p[i: i+k])
    if pos < _t:
        pos = _t
        rmax = i

ans = 0.0
p = p[rmax: rmax+k]
p = sorted(p, reverse=True)

for i in range(k):
    if tmp[p[i]] == 0:
        t = 0
        for j in range(1, p[i]+1):
            t += j
            tmp[j] = t / j
        ans += tmp[p[i]]
    else:
        ans += tmp[p[i]]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(0.5*(sum(p[i:i+k])+k))
print("{:.6f}".format(max(lstp)))

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_k = sum(p[i:i+k])
    if(max < sum_k):
        max = sum_k

print((max + k)/2.0)

Submission status: Time Limit Exceeded

Solution code:
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
past = -2000
for el in range(N - K + 1):
    tar = sum(p[el: el + K])
    if past < tar:
        past = tar
print(past)

Submission status: Time Limit Exceeded

Solution code:
def calcExValue(N):
    ev = []
    for i in range(1, N +1):
        ev.append(i * (1/N))
    return(sum(ev))

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

max_numbers = []
max_num = 0
for i in range(N-K+1):
    if sum(array[i:i+K]) > max_num:
        max_num = sum(array[i:i+K])
        max_numbers = array[i:i+K]

exv = 0
for n in max_numbers:
    exv += calcExValue(n)
    
print(exv)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

kitaichi_list = []
for i in p_list:
  sum_1 = sum(range(1,i+1))
  kitaichi_list.append(sum_1 / i)

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

print(j)

Submission status: Time Limit Exceeded

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

    Max = 0
    Max1 = 0
    for i in range(N-K+1):
        Max1 = 0
        for k in range(i,i+K):
            Max1 += (p[k]+1)/2
        if Max1 > Max:
            Max = Max1
    print(Max)

main()

Submission status: Time Limit Exceeded

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 0
be = 0

for i in range(a[0]-a[1]+1):
    sum = 0
    if be < b[i+a[1]-1]:
        for j in range(a[1]):
            sum += (1 + b[i+j])/2
        if ans < sum:
            ans = sum
    be = b[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def ex_value(dice):
  n = 0
  for i in range(1,dice+1):
    n += i*1/dice
  return(n)


def main():
  n,k = map(int, input().split())
  list_p = list(map(int, input().split()))
  list_ex_val = list(map(ex_value, list_p))
  sum_k=[]
  for i in range(n-k+1):
    sum_k.append(sum(list_ex_val[i:i+k]))
  print(max(sum_k))
     
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * (n+1)
ans = 0.0

for i in range(n):
    if i < k_range-1:
        e_list[i] = calc_expected_value(p[i])
    else:
        e_list[i] = calc_expected_value(p[i])
        ans = max(ans, sum([e_list[i-k] for k in range(k_range)]))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = a[0] - a[1]
e = []
for i in range(0,d+1):
	e.append(sum(b[i:i+a[1]]))
f = max(e)
g = e.index(f)
h = sum(map(lambda x : (x+1)/2, b[g:g+a[1]]))
print(h)

Submission status: Time Limit Exceeded

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

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):
    Sum=0
    if i+K<=N:
        for j in range(K):
            Sum += p[i + j]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
Sum=0
for i in range(K):
    kitai=1/2*p[index+i]*(p[index+i]+1)
    kitai = kitai / p[index+i]
    Sum+=kitai
print(Sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
P = np.array([float(i)/2.0*(float(i)+1.0)/float(i) for i in input().split()])
m = np.ones(K)
ev_sums = np.convolve(P, m, mode='valid')
print(np.max(ev_sums))

Submission status: Time Limit Exceeded

Solution code:
import statistics
n,k=map(int,input().split())
p_=input().split()
p=[]
for i in p_:
    p.append(int(i))
max=[]
for i in range(n-k+1):
    num=[]
    for j in range(k):
        num.append(p[i+j])
    if sum(num)>sum(max):
        max=num
result=0
for i in max:
    l=[]
    for j in range(1,i+1):
        l.append(j)
    result+=statistics.median(l)
print(result)

Submission status: Time Limit Exceeded

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

max_average = 0
point = 0
for i in range(len(P)-K+1):

    if max_average < sum(P[i:i+K]):
        max_average = sum(P[i:i+K])
        point = i

count = 0
for p in range(point, point+K):
    count += sum(range(1, P[p]+1)) / P[p]

print(count)

Submission status: Time Limit Exceeded

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

tmp_max = 0
tmp_pair = []
for i in range(len(p)-K+1):
    #print(p[i:i+3])
    if sum(p[i:i+K]) > tmp_max:
        # 最大値更新
        tmp_max=sum(p[i:i+K])
        # 最大値のペアを変更
        tmp_pair=p[i:i+K]
        
#print("tmp_max", tmp_max)
#print("tmp_pair",tmp_pair)

def kitaichi(dice):
    
    dice = range(1,dice+1)#サイコロの事象
    ex = 0#期待値を演算するための変数
    p = 1/len(dice)#サイコロの確率

    tmp = np.array(dice)
    
    ex = tmp * p
    
    #print("EX = ",sum(ex))
    return(sum(ex))

print(kitaichi(tmp_max+K-1))

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 = 1 + 0.5 * (p - 1)
X = 0

for i in range(N):
    if i + K > N:
        break
    else:
        if X <= sum(q[i:i+K]):
            X = sum(q[i:i+K])
        # X.append(sum(q[i:i+K]))

print(X)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
dice = list(map(int, input().split()))#dic=[]


p=[0]*(N-K+1)
for j in range(N-K+1):
    su=sum(dice[j:j+K])
    p[j]=su
print((max(p)+K)/2)

Submission status: Time Limit Exceeded

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

Max = k
min = 0
mel = 0
c = 0
S = []

while(Max <= n):
  for i in range(min, Max):
    for j in range(1, p[i]+1):
      c += j
    c = c / p[i]
    mel = mel +c
    c = 0
  S.append(mel)
  mel = 0
  Max += 1
  min += 1

print(max(S))

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

begin = 0
till = K

max = 0
for i in range(N-K+1):
    partial = np.sum(p[begin:till])
    if(max < partial): max = partial
    begin += 1
    till += 1



print((max + K) / 2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
d = input().split()
calc = []
d = [1 + 0.5*(int(i)-1) for i in d]
tmp = 0
result = 0

for i in range(1,n-k+2):
  for j in range(i,i+k):
    tmp += d[j-1]
  if result <= tmp:
    result = tmp
  tmp = 0

print(result)

Submission status: Time Limit Exceeded

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

res = 0
for i in range(n-k+1):
  d = sum(a[i:i+k])/2+0.5*k
  if res < d:
    res = d
print(res)

Submission status: Time Limit Exceeded

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

index=[]
ans = 0

for i in range(len(p)-k+1):
    count = 0
    for j in range(k):
        count += p[i+j]
    index.append(count)
l=index.index(max(index))

for m in range(k):
    for n in range(1, p[l+m] + 1):
            ans += n/p[l+m]
print(ans)

Submission status: Time Limit Exceeded

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



a=N-K+1
s=[0]*a
for i in range(a):
    s[i]=sum(p[i:(i+K)])
k=max(s)
print((k+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


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

que = []

S = 0
ans = 0
for i in range(N):
   S += E[i]
   que.append(E[i])

   if (i >= K):
       x = que[0]
       S -= x
       que.pop(0)

   ans = max(ans, S)

print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
#from numba import jit

def search(N, K, ps, ps_means, maxval):
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            #print(i)
            #print(K)
            a = ps[i-K+1:i+1]
            #print(a)
            b = [np.delete(a, i).prod() for i in range(K)]
            #print(b)
            c = ps_means[i-K+1:i+1] * b
            #print(c)
            sumval = np.sum(c) / a.prod()
            if sumval > maxval:
                maxval = sumval
    #print(ps_means)
    return maxval

def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")

    ps_means = np.zeros(N)
    maxval = 0
    ans = search(N, K, ps, ps_means, maxval)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = list(map(int, input().split()))
    p = list(map(int, input().split()))
    n = N-K+1
    kitai = [None] * n
    for i in range(N-K+1):
        kitai[i] = ((sum((p[i:i+K]))+K)*0.5)
    print('{:.12f}'.format(max(kitai)))
main()

Submission status: Time Limit Exceeded

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

# １からNまでの値をもつサイコロを振ったときの期待値
def ex(x:int):
    return (x*(x+1)/2)/x

# 期待値のリストを作る
kitaichi = []
kitaichi_goukei = []
for i in range(len(p)):
    kitaichi.append(ex(p[i]))
    if i+1 >= k:
        kitaichi_goukei.append(sum(kitaichi[i+1-k:i+1]))
print (max(kitaichi_goukei))

Submission status: Time Limit Exceeded

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

list_ans = []

for i in range(n-k+1):
    list_sum = list_score[i:i+k]
    list_ans.append(sum(list_sum))

list_ans.sort()


ans = list_ans[-1]*0.5 + 0.5*k

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
d = [0]
max_i = 0
t = 0
for i in range(len(p)):
  d.append(d[-1]+p[i])
  if i < k: continue
  if d[i+1]-d[i-k+1] > t:
    t = d[i+1]-d[i-k+1]
    max_i = i-k+1
ans = sum([sum(range(i+1))/i for i in p[max_i:max_i+k]])
print(ans)