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_n = list(map(int, input().split()))

s = 0
max_s = 0

for i in range(n - k + 1):
    s = sum(p_n[i:i + k])

    if s > max_s:
        max_s = s

print((max_s + k) / 2)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n ,k = i2()
p = intl()
def sx(n):
    return (n+1)/2

m = 0
pnt = 0
for i in range(0,n-k+1):
    s = sum(p[i:i+k])
    if s > m:
        m = s
        pnt = i
cnt = 0
for j in range(pnt,pnt+k):
    cnt += sx(p[j])
print(cnt)

Submission status: Time Limit Exceeded

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

nums = []

for i in range(N - K + 1):
    num = 0
    for j in range(i, i + K):
        num += p[j]
    nums.append([i, num])

ans = 0


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


nums_max = max(nums, key=lambda x: x[1])

for i in range(nums_max[0], nums_max[0] + K):
    ans += func(p[i]) / p[i]

print(ans)

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))
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:
n, k = map(int, input().split())

dice = list(map(int, input().split()))
a = 0
b = 0

a = sum(dice[0: k])
b = sum(dice[0: k])

res = 0
ll = 0
s = 0
for i in range(k, len(dice)):
    a += dice[i]
    a -= dice[s]
    if a > b:
        b = a
        ll = i
    s += 1

for mn in range(ll - k + 1, ll + 1):
    ss = range(dice[mn] + 1)
    res += sum(ss) / dice[mn]
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(i) for i in input().split()]
p = [0.5*(int(j)+1) for j in input().split()]

exp = 0e0
max = 0e0
maxi = -1


for l in range(n-k+1):
    exp = 0
    for m in range (l, l+k):
        exp += p[m]#0.5*(p[m]+1)

    if(exp > max):
        max = exp
        maxi = l

#out = 0
#for aa in range (maxi,maxi+k):
#    out += 0.5*(p[aa]+1)

print(max)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = [int(s) for s in input().split()]

l = [0] * (N - K + 1)
for i in range(N - K + 1):
    l[i] = sum(p[i:i+K])


print("{:.12f}".format((max(l)+K) /2))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
p_value = list(set(p_list))
p_dic = {}
avg = 0

for i in range(len(p_value)):
    sums = 0
    for j in range(1,p_value[i]+1):
        sums += j

    v = sums/p_value[i]
    p_dic.update({p_value[i] : v})

for i in range(N-K+1):
    total = 0
    for j in range(K):
        total += p_dic[p_list[i+j]]
    
    avg = total if avg < total else avg

print(avg)

Submission status: Time Limit Exceeded

Solution code:
def EV(num):
    sum=0
    for j in range(1,num+1):
        sum+=j
    return sum/num

if __name__=="__main__":
    n,k=map(int,input().split())
    p=list(map(int,input().split()))

    exp={}

    ans=0
    cnt=0

    for j in range(0,n-k+1):

        tmp=0
        for i in range(k):
            if p[i+cnt] not in exp:
                exp[p[i+cnt]] = EV(p[i+cnt])
            tmp+=exp[p[i+cnt]]
        if ans < tmp:
            ans=tmp
        cnt += 1

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

best=0

for i in range(N-K+1):
  point=P[i:i+K].sum()
  
  if point>best:
    best=point
    
    


print(best/2+K/2)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict


def main(n, k, p: list):
    ans = 0

    memo = defaultdict(int)

    for i in range(n - k + 1):
        t = 0
        for j in p[i : i + k]:
            if memo[j] == 0:
                for _k in range(1, j + 1):
                    memo[j] += _k * (1 / j)

            t += memo[j]

            ans = max(ans, t)

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


if __name__ == "__main__":
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    main(n, k, p)

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)

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

print(max_E)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
obj_list=[0]
for i, a in enumerate(p):
   if np.sum(obj_list)<np.sum(p[i:i+K]):
       obj_list = p[i:i+K]
ans = 0
for i in obj_list:
    a = sum(range(0,i+1,1))/i
    ans += a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k= map(int, input().split())
p = list(map(int, input().strip().split()))

l=[]
m=0
po=0

for i in range(len(p)-k+1):  
    s=0
    for j in range(k):
        s+=p[i+j]
    if(s > m):
        m = s
        po = i

sp = np.zeros(k)
for j in range(k):
    sp[j]= (p[po+j]+1)/2

print(float(np.sum(sp)))

Submission status: Time Limit Exceeded

Solution code:
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]
#print(ln_mean)

lnk = [0]*(n - k + 1)
for i in range(n - k + 1):
  tmp_lnk = ln_mean[i:i+k]
  lnk[i] = sum(tmp_lnk)

print(max(lnk))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = P[:K]
ans = sum(memo)

for i in range(K, N):
    memo.pop(0)
    memo.append(P[i])
    tmp = sum(memo)
    if tmp > ans:
        ans = tmp

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
p =list(map(int,input().split()))
pp =[]
for i in range(len(p) - k + 1):
  tmp = 0
  for j in range(k):
    tmp += p[i+j]
  pp.append(tmp)
mn = max(pp)
ans = (mn + k) / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
for j in range(N-K+1):
    if j==0:
        kouho.append(kitaiti)
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako.pop(0)
        kouho.append(kitaiti)
#print(kouho)
print(max(kouho))

Submission status: Time Limit Exceeded

Solution code:
N, K = input().split(" ")
pList = input().split(" ")

maxEx = 0

for index, k in enumerate(pList):
    kList = pList[index:index + int(K)]

    if int(K) != len(kList):
        break
    
    eX = 0

    for element in kList:
        eX += sum([n for n in range(1, int(element) + 1)]) / int(element)
    
    if maxEx < eX:
        maxEx = eX

print(maxEx)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

  def CalExVal(x):
      return (1/2*(x+1))
  Ex = np.array(list((map(CalExVal, A))))
  temp = len(A)-K + 1
  #adjlist = [0]*(temp)
  adjlist = [np.sum(Ex[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:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = [(i+1)/2 for i in B]
h = []
for l in range(A[0]-A[1] +1):
  h.append(sum(k[l: l + A[1]]))
print(max(h))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
ans = []
maxv = max(p)
dp = [i+1 for i in range(maxv+1)]
for i in range(1,maxv+1):
    dp[i] = dp[i-1]+dp[i]
dp = [j/(i+1) for i,j in enumerate(dp)]

maxv = 0
for i in range(n-k+1):
    a = 0
    for j in range(i,i+k):
        a += dp[p[j]-1]
    if maxv < a:
        maxv = a
    
print(maxv)

Submission status: Time Limit Exceeded

Solution code:
def kitai(x):
  k = ((x*(x+1))/2)/x
  return k

n, k = map(int, input().split())
p = list(map(int, input().split()))
ki_l = []
ans_l = []
for i in p:
  ki_l.append(kitai(i))
for i in range(n - k + 1):
  ans_l.append(sum(ki_l[i:i+k]))
print(max(ans_l))

Submission status: Time Limit Exceeded

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

max_pos = 0
max_value = 0
for i in range(len(P)):
    if i + K > len(P):
        break
    tmp_sum = sum(P[i:i+K])
#    print(i, tmp_sum, P[i:i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += sum(list(range(1, P[i] + 1))) / P[i]
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)

Submission status: Time Limit Exceeded

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

max_index = 0
max_val = 0
for i in range(N-K+1):
    n = 0
    for j in range(K):
        n += P[i+j]
    if max_val < n:
        max_val = n
        max_index = i

ans = 0

for k in range(K):
    ans += 1.0/2.0*(P[max_index+k]+1)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
  import sys
  input = sys.stdin.readline 
  N,K=map(int,input().split())
  diceList=tuple([(int(x)+1)/2 for x in input().split()])

  maxNum=0
  st=0
  for i in range(N-K+1):
    for j in range(K):
      st+=diceList[i+j]
    if(st>=maxNum):
      maxNum=st
    else:
      pass
    st=0
  print(maxNum)

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
    n, k = map(int, input().split())
    arr = list(map(int,input().split()))

    tmp = 0
    tmp_arr = []
    for i in range(n - (k - 1)):
        sum_tmp = sum(arr[i:i+k])
        if sum_tmp >= tmp:
            tmp = sum_tmp
            tmp_arr = arr[i:i+k]
    ans = 0
    for j in tmp_arr:
        tmp_sum = 0
        for m in range(1, j+1):
            tmp_sum += m
        ans += tmp_sum / j
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(x) for x in input().split())
X = list((int(x) for x in input().split()))
#E = list(map(lambda x: sum(range(x+1))/x, X))
max_hoge = 0
max_list = []
for i in range(N-K+1):
  if sum(X[i:i+K]) > max_hoge:
    max_list = X[i:i+K]
    max_hoge = sum(X[i:i+K])
ans = 0
for j in max_list:
  ans += sum(range(j+1))/j
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
for j in range(N-K+1):
    if j==0:
        kouho.append(kitaiti)
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako.pop(0)
        kouho.append(kitaiti)
#print(kouho)
print(max(kouho))

Submission status: Time Limit Exceeded

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

l = []

s = 0
flag = 0

for i in range(n):
    l.append(((1 + p[i]) * p[i] / 2) / p[i])

for i in range(n - k + 1):
    for j in range(k):
        s += l[j + i]
    if s > flag:
      flag = s
    s = 0

print(flag)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
l = list(map(int,input().split()))
#print(l)

x =0
y = 0
for i in range(n-k+1):
    if x < max(sum(l[i:i+k]),x):
        x = sum(l[i:i+k])
        y = i
#print(x,y)

z = 0
for j in range(y,y+k):
    z += (l[j]+1)/2

print(z)

Submission status: Time Limit Exceeded

Solution code:
n, k, *p = map(int, open(0).read().split())

p = tuple(p)
max_r = 0
max_i = 0
for i in range(n-k+1):
  r = sum(p[i:i+k])
  
  if r > max_r:
    max_r = r
    max_i = i
    
max_e = 0
for j in range(max_i, max_i+k):
  max_e += (p[j]+1)/2

print(max_e)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def Expected_Value(x):
    EV = 0
    for i in range(1,x+1):
        EV += i/x
    return EV
N, K = map(int, input().split())
pi = np.array(list(map(int, input().split())))
ma = 0
for i in range(N-K+1):
    x = sum(pi[i:i+K])
    if x > ma:
        ma = x
        max_index = i
array_max = (np.array(pi[max_index:max_index+K])-1) *0.5 + 1
print(array_max.sum())

Submission status: Time Limit Exceeded

Solution code:
n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda x: sum(x)/len(x)+1, map(range, dices)))
exp=0
for i in range(n-t+1):
  d = avg[i:i+t]
  exp = max(exp, sum(d))
print(exp)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from scipy.signal import convolve

n, k = map(int, input().split())
P = np.array(input().split(), dtype=int)
template = np.ones(k)

a = convolve(P, template, mode="valid")

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

Submission status: Time Limit Exceeded

Solution code:
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))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
s = list(map(float, input().split()))
t =[]
wa= 0
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
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
ave = np.convolve(p, np.ones(K)/float(2), 'valid')
print(max(ave) + K/2)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


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

    max = 0
    idx = 0
    E = []
    for n in range(N):
        if n <= N-K:
            sums = sum(P[n:n + K])
            if max < sums:
                max = sums
                idx = n

    print(sum(map(calc_e, P[idx:idx+K])))


def calc_e(v):
    return 0.5 * (1 + v)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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

for i in range(0, n):
  p[i]=(p[i]+1)*p[i]/(p[i]*2)#p[i]が期待値になった

list00=[]
for j in range(0, n-k+1):
  list00.append(sum(p[j:j+k]))

y = sorted(list00)
print(y[n-k])

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    P = []
    for i in range(N):
        if p[i] != 1:
            P.append((p[i]+1)/2)
        else:
            P.append(1)
    Max = 0
    Max1 = 0
    for i in range(N-K+1):
        Max1 = 0
        for k in range(i,i+K):
            Max1 += P[k]
        if Max1 > Max:
            Max = Max1
    print(Max)

main()

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=list(map(int, input().split()))
res=[]
for a in A:
    tmp=0
    for i in range(1,a+1):
        tmp+=i
    res.append(tmp/a)
cnt=0
for i in range(N):
    if K+i<=N:
        B=sum(res[i:K+i])
        if cnt<B:
            cnt=B
print(cnt)

Submission status: Time Limit Exceeded

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

N = list(map(int,input().split()))[1]
ans = 0
numbers = list(map(int,input().split()))
numbers = list(map(mean,numbers))
for x in range(len(numbers)-N+1):
    ans = max(ans, sum(numbers[x:x+N]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = 0.0
for j in range(a - b + 1):
    k_list = num_list[j:j+b]
    k_sum = max(k_sum, sum(k_list))

out = (k_sum + b) / 2
print(out)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def cal_ans(x):
    ans = (x*(x+1)/2)/x
    return ans
n,k = map(int,input().split())
p = np.array(list(map(int,input().split())))
p = np.array(list(map(cal_ans,p)))

ans_temp = 0
ans_list = []
for i in range(n):
    try:
        if ans_temp < np.sum(p[i:i+k]):
            ans_temp = np.sum(p[i:i+k])
    except:
        pass
print(ans_temp)

Submission status: Time Limit Exceeded

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

sum_max = 0
for i in range(n-k+1):
  sum_max = max(sum_max, sum(nums[i:i+k]))

print((sum_max +k)/2)

Submission status: Time Limit Exceeded

Solution code:
i = input().split()
n = int(i[0])
nannko = int(i[1])
i2 = input().split()
nAr = [int(s) for s in i2]
newArr = []

max = 0
for j in range(n - nannko + 1):
    li = nAr[j:j+nannko]
    newArr.append(li)
targetArr = [0]
for k in range(len(newArr)):
  if (sum(newArr[k]) > sum(targetArr)):
      targetArr = newArr[k]
for l in range(len(targetArr)):
    max += (targetArr[l] + 1)/2
print(float(max))

Submission status: Time Limit Exceeded

Solution code:
def calc(num):
    return num * (num + 1) / 2 * (1 / num)

N, K = [int(i)for i in input().rstrip().split(' ')]
_p = [int(i)for i in input().rstrip().split(' ')]
maxs = 0
idx = 0;

v = N-K+1

for i in range(v):
    l = [_p[j] for j in range(i, i+K)]
    if sum(l) <= maxs: continue;
    idx = i;
    maxs = sum(l)

s = [calc(_p[i]) for i in range(idx, idx+K)]
print(sum(s))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
f = lambda x: int(x)+1
np_P = np.array(list(map(f, input().split())))
v = K*[1/2]
print(np.amax(np.convolve(np_P,v)))

Submission status: Time Limit Exceeded

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

arr = []
tmp = 0

for n in P:
  arr.append((n+1)/2)

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

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

Submission status: Time Limit Exceeded

Solution code:
def ex(x):
    s = 0
    p = 1/x
    for i in range(1, x+1):
        s = s + p*i
    return s


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

m = 0

for j in range(n-k+1):
    sum = 0
    for i in range(j, j+k):
        sum = sum + ex(p[i])
    m = max(sum, m)

print(m)

Submission status: Time Limit Exceeded

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

def kitaichi(p):
  s = 0
  for i in range(1,p+1):
    s = s + i / p
  return s

W = []

for k in range(N):
  sum = 0
  for l in range(k, min(k+K, N)):
    sum = sum + kitaichi(List[l])
  W.append(sum)
print(max(W))

Submission status: Time Limit Exceeded

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

dct = {}
for i in range(0, len(P)):
    if len(P[i:i+K])==K:
        p_k = P[i:i+K]
        dct[sum(p_k)] = p_k

E = sum([sum([i for i in range(1,dice+1)]) / dice for dice in dct[max(dct)]])
print('{:.12f}'.format(E))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = input().split()
ex = [0 for i in range(N)]
E=0
def expectation(n):
    return (n+1)/2
def ran(n,k,i):
    if i+1>=K and N-(i) >= K:
        return K
    elif i+1 < K:
        return i+1
    else:
        return N-i

for i in range(N):
    p[i] = int(p[i])
    ex[i] = expectation(p[i])

X=N-K+1

for i in range(X):
    newE = 0
    for j in range(K):
        newE += ex[i+j]

    if newE > E:
        E = newE

    
    

print(E)

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=[]
for i in P:
    Q.append(calc(i))

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:
def main():
	import sys
	input=sys.stdin.readline
	all,rolls=map(int,input().split())
	List=list(map(int,input().split()))

	sum = 0
	sumList =[]

	for i in range(all - rolls + 1):
		sum = 0
		for j in range(rolls):
			sum = sum + (List[i + j] + 1) / 2
		sumList.append(sum)

	sumList.sort(reverse=True)
	print(sumList[0])

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
m = []
s = []
j = 0
for i in range(1, 1001):
    j += i
    s.append(j/i) 

for i in range(n-k+1):
    l.append(p[i:i+k])
    m.append(sum(p[i:i+k]))
Max_index = m.index(max(m))

ll = l[Max_index]
ans = 0
for i in ll:
    ans += s[i-1]
print(ans)

Submission status: Time Limit Exceeded

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

d = {}
def kitaichi(n):
	if n in d.keys(): return d[n]
	else:
		sum = n * (n+1) / 2
		d[n] = sum / n
		return d[n]

idx = 0
mx = 0
for i in range(len(p)):
	pp = p[i:i+k]
	if len(pp) != k: break
	if mx < sum(pp):
		mx = sum(pp)
		idx = i

ans = 0
for i in p[idx:idx+k]:
	ans += kitaichi(i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import decimal

def sigma(i):   
    total = 0
    for k  in range(1,i+1):
        total += k
    return total



input_first = input().split()
input_second= input().split()
N = int(input_first[0])
K = int(input_first[1])
in_list = [int(i) for i in input_second]

expect = []

for i in in_list:
    value = float(sigma(i)/i)
    expect.append(value)


# print(expect)
summ  = 0
for j in range(N-K+1):
    tmp = 0
    for p in range(K):
        # print("j",j,"p",p+j)
        tmp += expect[p+j] 


    if tmp > summ:
        summ = tmp
    # print("tmp",tmp)
print('{:.12f}'.format(summ))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

m = 0

for i in range(N-K+1):
	ans = 0
	for j in range(i, i+K):
		ans += np.mean(np.array(range(1, x[j]+1))) 

	if ans > m:
		m = ans

print(m)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def expected_value(me):
  return ((1/2)*me*(me+1))/me

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

kaisu = n-k + 1
point = 0
res = 0
for j in range(kaisu):
  temp = np.sum(num_p[j:j+k])
  if res < temp:
    res = temp
    point = j

max_p = p[point:point+k]
kitai = [expected_value(i) for i in max_p]
print(sum(kitai))

Submission status: Time Limit Exceeded

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

for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += a[i + j]
    if d > max_d:
        max_i = i
        max_d = d
ans = 0
for i in range(max_i,max_i + k):
    ans += (1 + a[i])/2
print(ans)

Submission status: Time Limit Exceeded

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

P_total = sum(P)

max_sum = 0

if K < (N/2):
    for i in range(N-K+1):
        tmp_sum = sum(P[i:i+K])
        if tmp_sum > max_sum:
            max_sum = tmp_sum
else:
    for i in range(N-K+1):
        tmp_sum = P_total - sum(P[0:i]) - sum(P[i+K:])
        if tmp_sum > max_sum:
            max_sum = tmp_sum

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map( int, input().split())
    P = list(input().split())
    max_ex = 0
    
    for i in range(N-K+1):
        sum_ex = sum(1.0/float(P[j])*float(P[j])*(float(P[j])+1)/2 for j in range(i,i+K))
        if sum_ex>max_ex:
            max_ex = sum_ex
    print(max_ex)
        

    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    P = []
    for i in range(N):
        if p[i] == 1:
            P.append(1)
        else:
            P.append((p[i]+1)/2)
    Max = 0
    Max1 = 0
    for i in range(N-K+1):
        Max1 = 0
        for k in range(i,i+K):
            Max1 += P[k]
        if Max1 > Max:
            Max = Max1
    print(Max)

main()

Submission status: Time Limit Exceeded

Solution code:
E = lambda x: x if x==1 else (x+1)*(x/2)/x
N, K = map(int, input().split())
Es = [E(pi) for pi in map(int, input().split())]
print(max([sum(Es[i:i+K]) for i in range(N+1-K)]))

Submission status: Time Limit Exceeded

Solution code:
def ex(x):
    res = 0
    for i in range(1, x+1):
        res += i/x
    return res

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:
def ex_value(dice):
    n = 0
    for i in range(1,dice+1):
        n += i*1/dice
    return(n)
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))

Submission status: Time Limit Exceeded

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

A = []
for i in P:
    A.append(1/2*(i+1))

ans = 0
for i in range(len(A)):
    ans = max(ans,sum(A[i:i+K]))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = (int(x) for x in input().split())
X = list((int(x) for x in input().split()))
E = list(map(lambda x: sum(range(x+1))/x, X))
max_hoge = 0
max_list = []
for i in range(N-K+1):
  if sum(E[i:i+K]) > max_hoge:
    max_list = E[i:i+K]
    max_hoge = sum(max_list)
print(max_hoge)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def E(x):
    z=1/x*(1+x)*x/2
    return z


a=N-K+1
s=[0]*a
for i in range(a):
    s[i]=sum(p[i:(i+K)])
k=s.index(max(s))    
z=0
for i in range(K):
    ans=E(p[k+i])
    z+=ans

print(z)

Submission status: Time Limit Exceeded

Solution code:
a = input().split()
b = input().split()

ans = 0
be = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

List_a = []
it = 0
for i in range(N-K+1):
    List_a.append(sum(List[i:i+K]))

it = List_a.index(max(List_a))
answer = sum(list(map(lambda x:(1+x)/2, List[it:it+K])))

print(answer)

Submission status: Time Limit Exceeded

Solution code:
def sgm(i):
    sum=0
    for j in range(i+1):
        sum+=j
    return sum

n, k=map(int, input().split())
p=list(map(int, input().split()))
idx=0
max=0
sum=0
for i in range(n-k+1):
    for j in range(k):
        sum+=p[i+j]
    if sum>=max:
        max=sum
        idx=i
    sum=0

e=0
for i in range(idx,idx+k):
    e+=(sgm(p[i])/p[i])
print(e)

Submission status: Time Limit Exceeded

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

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

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:
N,K=map(int,input().split())
dice = list(map(int, input().split()))#dic=[]


#def calc(n):
#    return (n+1)/2
#t1=time.time()
#data = list(map(calc, dice))
#t2=time.time()
#t3=time.time()
p=[]
for j in range(N-K+1):
    su=sum(dice[j:j+K])
    p.append(su)
#t4=time.time()
print((max(p)+K)/2)