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:

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

    max_sum = 0
    rangeN = n - k + 1
    # for i in range(rangeN):
    #     # print(i, p, k)
    #     r = sum(p[i:i + k])
    #     # print(r)
    #     if r > max_sum:
    #         max_sum = r

    r_array = [sum(p[i:i + k]) for i in range(rangeN)]
    print((max(r_array) / 2) + (k * 0.5))

Submission status: Time Limit Exceeded

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

for i in range(len(ki)-k+1):
    su = 0
    for j in range(i,i+k):
        su += ki[j]
    l.append(su)

print(max(l))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_bef = list(map(int, input().split()))
p_aft = []
a = 0
for i in range(n-k+1):
   for j in range(i, i+k):
      a += p_bef[j]
   p_aft.append(a)
   a = 0
p_aft2 = sorted(p_aft, reverse = True)
print((p_aft2[0]+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from decimal import Decimal

def expectval(num):
    up = [Decimal(str(n)) for n in range(1, num+1)]
    return sum(up) / Decimal(str(num))

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

ans = Decimal("-1")
for idx in range(len(l)):
    comb = l[idx:idx+k]
    _sum = 0
    for n in comb:
        _sum += expectval(n)
    if _sum > ans:
        ans = _sum

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

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((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:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))

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

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

print(sum(kitaichi_list))

Submission status: Time Limit Exceeded

Solution code:
def solve(_list,_k):
  start = 0
  _sum = -1
  for i in range(len(_list)-_k+1):
    s = sum(_list[i:i+_k])
    if _sum < s:
      _sum = s
      start = i

  ans = (_sum+_k) / 2
  return ans


if __name__ == "__main__":
  _n, _k = map(int, input().split())
  _l = [int(i) for i in input().split()]

  result = solve(_l, _k)
  print(result)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
m=[0]*(n-k+1)

for i in range(0,n-k+1):
    s=0
    for j in range(i,i+k):
        s=s+A[j]
    m[i]=s
print((max(m)+k)/2)

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])
  exps.append(p[ii]*(p[ii]+1)/(2*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:
import numpy as np
n,k = list(map(int,input().split()))
p = np.array(list(map(int,input().split())))

P = [p[i:i+k].sum() for i in range(n-k+1)]
mp = p[np.argmax(P):np.argmax(P)+k]

ans = 0
for i in mp:
  j = i//2
  if i%2 == 0:
    ans += ((i+1)*j)/i
  else:
    ans += ((i+1)*j + j + 1)/i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,input().split())
p = list(map(int,input().split()))

bigPoint = 0
bigNumber = 0

for i in range(x-y+1):

    number = sum(p[i:i+y])

    if number > bigNumber:
        bigNumber = number
        bigPoint = i

print((bigNumber + y) / 2)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=tuple(map(int,input().split()))
cnt=0.0
for i in range(N-K+1):
  S=sum(P[i:i+K])
  S=(S+K)/2.0
  cnt=max(cnt,S)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def dice_eq(x):
    eq=0
    for i in range(x):
        eq+=(i+1)/x
    return eq
equit=0
N,K=map(int,input().split())
data=list(map(int,input().split()))
#print(data)
ansb=[]
for j in range(N):
    equit=dice_eq(data[j])
    ansb.append(equit)
kt=0
#print(ansb)
ansc=[sum(ansb[m:m+K]) for m in range(0,N-K+1)]
ansc.sort(reverse=True)
#print(ansc)
ans=ansc[0]
print(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(len(p)-K+1):
  ans = max(ans,((sum(p[i:i+K])+K)/2))
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 = [0]*(n-k+1)
for i in range(n-k+1):
    lstp[i] = (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())
dice = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

    ps_means = np.zeros(N)
    maxval = 0

    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            a = ps[i-K+1:i+1]
            b = 1 / a
            c = ps_means[i-K+1:i+1] * b
            sumval = np.sum(c)
            if sumval > maxval:
                maxval = sumval

    ans = maxval
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = input().split()
ans = [0]*n
win = []

for j in range(len(p)):
    for i in range(int(p[j])):
        ans[j] += int(i+1) * 1/int(p[j])

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

print(max(win))

Submission status: Time Limit Exceeded

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

max_e = 0

l = list(map(lambda x: (x + 1) / 2, p))

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

print(max_e)

Submission status: Time Limit Exceeded

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

m = p[0:K]
for i in range(1,N-K+1):
    if sum(m) < sum(p[i:K+i]):
        m = p[i:K+i]
e = np.array(m)
n = sum((1+e)/2) 
print(n)

Submission status: Time Limit Exceeded

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

def expected_value(dice):
  sum = 0
  for d in range(dice):
    sum = sum + d + 1
  return sum / dice

def sum_expected_value(start_index, dice_line, amount):
  sum = 0
  for i in range(amount):
    ev = expected_value(dice_line[start_index + i])
    sum = sum + ev
  return sum


max_sum_ev = 0
for n in range(N):
  if (n+K) > N:
    break
  sum_ev = sum_expected_value(n, p, K)
  if sum_ev > max_sum_ev:
    max_sum_ev = sum_ev 

print(max_sum_ev)

Submission status: Time Limit Exceeded

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

import numpy as np
N = list(map(int,input().split()))[1]
ans = 0
numbers = np.array(list(map(float,input().split())))
numbers = (numbers+1.0)/2.0
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:
N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  sum = int(p[i])*(int(p[i])+1)/2
  expected_list.append(float(sum/(int(p[i]))))
  
for i in range(N):
  anan = 0
  for j in range(K):
    try:
      anan += expected_list[i+j]
    except:
      pass
  max_list.append(anan)
  
print(max(max_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

l_kitaichi = [sum([(1 + p[i+j]) / 2 for j in range(K)]) for i in range(N - K + 1)]

print(float(max(l_kitaichi)))

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from decimal import Decimal

def expectval(num):
    up = [Decimal(str(n)) for n in range(1, num+1)]
    return sum(up) / Decimal(str(num))

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

ans = Decimal("-1")
for idx in range(len(l)):
    comb = l[idx:idx+k]
    _sum = sum(map(expectval, comb))
    if _sum > ans:
        ans = _sum

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

Submission status: Time Limit Exceeded

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

ans_temp = 0
ans_list = []
for i in range(n-k+1):
    if ans_temp < sum(p[i:i+k]):
            ans_temp = sum(p[i:i+k])
print(ans_temp)

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]
  e += 0.5 * k
  if e_max < e:
    e_max = e

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

Submission status: Time Limit Exceeded

Solution code:
Input = list(map(int,input().split()))

N = Input[0]
K = Input[1]

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

Inp_ar = Input

for i in range(N):
  Inp_ar[i] = sum(list(range(Inp_ar[i]+1)))/Inp_ar[i]

add=0
ar=[]

for i in range(N-K+1):
  add = sum(Inp_ar[i:i+K])
  ar.append(add)

print(max(ar))

Submission status: Time Limit Exceeded

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

max_k = 0
max_v = []
for i in range(0, len(P)):
    if len(P[i:i+K])==K:
        p_k = P[i:i+K]
        if max_k<=sum(p_k):
            max_k=sum(p_k)
            max_v=p_k

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

Submission status: Time Limit Exceeded

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

ans = []
l = []
for i in range(N-K+1):
    l.append(sum(P[i:i+K]))
idx = l.index(max(l)) 
ls = P[idx:K+idx]
for j in range(K):
    ans.append((ls[j]+1)*ls[j]/(2*ls[j]))
print(sum(ans))

Submission status: Time Limit Exceeded

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

for i in range(1,n-k+1):
    if p[i-1] < p[i+k-1]:
        s1 = sum(p[i:i+k])
        if s1 > s:
            idx = i
            s = s1


l = [(1 + p1)*(p1//2 + 0.5*(p1%2))/p1 for p1 in p[idx:idx+k]]

print(sum(l))

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

def Kitaichi2(p):
    return (p+1)*0.5

kitaichi_list=[]
for a in range(N):
    kitaichi_list.append(Kitaichi2(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())
P = list(map(int, input().split()))
mx = 0
num = 0

def hoge(n):
  return n * ( 1.0 + n ) / 2.0 / n

for i in range(0,len(P)-k+1):
  num = 0
  for j in range(i , i+k):
    num = num + hoge(P[j])
    # print(str(i) + ": num : " + str(num))
  if mx < num:
    mx = num

print(mx)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力

def calc_expected(c):
    ans = 0
    for i in range(c):
        ans += (i+1) * (1 / c)
    return ans

a, b = map(int, input().split())
expected = 0
tmp_expected = 0
li = list(map(int, input().split()))
li2 = []

for i in range(a):
    li2.append(li[i])

for s in range(len(li2)):
    tmp_expected = 0
    for i in range(b):
        if s+i >= len(li2):
            break
        tmp_expected += calc_expected(li2[s+i])

    if tmp_expected >= expected:
        expected = tmp_expected

print(float(expected))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def main():
    StringN,StringK = input().split();
    ListA           = input();
    newListA        = ListA.split();
    temp            = 0;
    max             = 0;
    maxK            = 0;
    Kitaichi        = 0;
    i               = 0;
    j               = 0;
    #隣接するK個の最大値を求める
    for i in range(len(newListA) - int(StringK) + 1):
        j = i;
        temp = 0;
        for j in range(j, j + int(StringK)):
            temp = temp + int(newListA[j]);
        if max < temp:
            max = temp;
            maxK = i;


    #隣接するK個の期待値を求める
    for i in range(maxK, maxK + int(StringK)):
        Kitaichi = Kitaichi + (1 + int(newListA[i])) / 2;

    print(Kitaichi);

main();

Submission status: Time Limit Exceeded

Solution code:
def cal(a):
    cal_sum = 0
    for i in range(1, a + 1):
        cal_sum += i
    return (cal_sum / a)


N, K = map(int, input().split())
p = list(map(int, input().split()))
ans_raw = []
index = 0

for i in range(0, N):
    p[i] = cal(p[i])



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

max_raw = ans_raw[0]

for i in range(0, len(ans_raw)):
    if max_raw < ans_raw[i]:
        index = i
        max_raw = ans_raw[i]

print(max_raw)

Submission status: Time Limit Exceeded

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

p = np.array(p)
max_sum = 0
ind = 0
for i in range(n-k+1):
    tmp_sum = np.sum(p[i:i+k])
    if(max_sum < tmp_sum):
        max_sum = tmp_sum
        ind = i

nums = p[ind: ind+k]

r = 0
for num in nums:
    r += num / 2 + 0.5

print(r)

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_sum = max(k_sum, sum(num_list[j:j+b]))

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K=map(int, input().split())
Q=input().split()
P=np.array([list(map(int, Q[i:i+K])) for i in range(N-K+1)])

best=(P.sum(axis=1)).max()

"""
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:
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=[sum(list_ex_val[i:i+k]) for i in range(n-k+1)]
  print(max(sum_k))
     
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
n,k,*p = map(int, open(0).read().split())
l = []
for i in range (0,len(p)-k+1):
  s = sum(p[i:i+k]) 
  l.append(s)
max_val=max(l)
max_idx=l.index(max_val)
exp = []
for i in range (max_idx,max_idx+k):
  ex=0
  for k in range(1,p[i]+1):
    px = k*(1/p[i])
    ex = ex + px
  exp.append(ex)
print(sum(exp))

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 = p_list[scope_index:scope_index + k]
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())
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):
  tmp = sum(d[i-1:i+k-1])
  if result <= tmp:
    result = tmp

print(result)

Submission status: Time Limit Exceeded

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

max_e = 0
l = [0] * N

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

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

print(max_e)

Submission status: Time Limit Exceeded

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


def kitaichi(num):
    return (sum(range(num+1)) / num)

t = [0] * n
for i in range(n):
    t[i] = kitaichi(p[i])

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n, k = map(int, input().split())
P = deque(map(int, input().split()))

s_max = 0
popped = 0
P_max = deque([])
for i in range(k):
    popped = P.popleft()
    P_max.append(popped)
    s_max += popped
s = s_max
# print(s)
P_extracted = deque(list(P_max))
while P != deque([]):
    # print(P_extracted, P, P_max)
    s -= P_extracted.popleft()
    popped = P.popleft()
    s += popped
    # print(s)

    # P_extracted.popleft()
    P_extracted.append(popped)
    # print(P_extracted)
    if s_max < s:
        s_max = s
        P_max = deque(list(P_extracted))
        # print(s_max, P_max)

# print(s_max, P_max)
e = 0
for i in P_max:
    # tmp = 0
    e += sum(range(1, i+1)) / i
    # print(tmp)
    # e += tmp
print(e)

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())))
p = list(map(int, input().split()))
# q = 1 + 0.5 * (p - 1)
X = 0
Y = []

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

print(sum(1 + 0.5 * (np.array(Y) - 1)))

Submission status: Time Limit Exceeded

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

N,K=map(int,input().split())
P=tuple(map(int,input().split()))
Q=tuple(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()))

def calc(n):
    return sum([i for i in range(1, n+1)]) / n
ex = []
for i in p:
    ex.append(calc(i))
    
max_ex = 0
for i in range(0, N-(K-1)):
    temp = sum(ex[i:i+K])
    if temp > max_ex:
        max_ex = temp

print(max_ex)

Submission status: Time Limit Exceeded

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

ans_ind = max([sum(P[i:i+k]) for i in range(n - (k-1))])

print((ans_ind + k) * 0.5)

Submission status: Time Limit Exceeded

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

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

p_list = np.array(p_list)
b = np.ones(k)/k
p2 = lfilter(b, 1, p_list)
index = np.argmax(p2)
kitaichi = k/2 + k*p2[index]/2
print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
def judge(x, y):
  #if x < 0 or y < 0:
  #  return True
  if P[x] > P[y]:
    return True
  #if P[x] == P[y]:
  #  return judge(x-1, y-1)
  return False

N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
_sum = 0
for i in range(1, N - K + 1):
  if judge(i+K-1, i-1):
    tmp = sum(P[i:i+K])
    if tmp > _sum:
      _sum = tmp
      start = i
    #print(start)
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)
#print(P[start:start+K])

Submission status: Time Limit Exceeded

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

List_a = list(map(lambda x:(1+x)/2, List))

ma = 0
for i in range(N-K+1):
    if ma < sum(List_a[i:i+K]):
        ma = sum(List_a[i:i+K])

print(ma)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
pi = np.array(list(map(int, input().split())))
index = []
for i in range(N-K+1):
    x = sum(pi[i:i+K])
    index.append(x)
max_index = index.index(max(index))
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:
def expectedVal(p):
    res = 0
    for i in range(1, p+1):
        res += i / p
    # print("p:{} {}".format(p,res))
    return res

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

setP = set(P)
exDict = {}
for x in setP:
    exDict[x] = expectedVal(x)

m = n - k + 1

ans = 0
for i in range(m):
    total = 0
    # print(P[i:i+k])
    for p in P[i:i+k]:
        total += exDict[p]
    ans = max(ans, total)
    # print("i:{} ans:{}".format(i,ans))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
count = 0
MaxSum = 0
for _ in p:
    tmp_SumSlice = sum(p[count:count + K])
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
    count += 1 
print((MaxSum+K)/2)

Submission status: Time Limit Exceeded

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

from collections import deque
P_dq = deque(P, N)

P_sum = P
for i in range(K-1):
    P_dq.append(0)
    P_sum = list(map(sum, zip(P_sum, P_dq)))

max_sum = max(P_sum)

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

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 = sum(list_score[i:i+k])
    if list_sum >= list_ans:
        list_ans = list_sum




ans = list_ans*0.5 + 0.5*k

print(ans)

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 = []
    sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
    max_v = max(sum_tmp)
    max_i = sum_tmp.index(max_v)
    ans = 0
    for j in arr[max_i:max_i+k]:
        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:
#import numpy as np

N,K=map(int,input().split())
#p=np.zeros(N)
p=[0 for i in range(N)]
p=list(map(int, input().split()))

max=0
for i in range(len(p)-K+1):
    #all=np.sum(p[i:i+K])
    all=sum(p[i:i+K])
    if all>max:
        max=all
        ind=i

a=0
for i in range(ind,ind+K):
    a+=((p[i]*(p[i]+1))/2)/p[i]

print(a)

Submission status: Time Limit Exceeded

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

P = np.zeros(n)
for i in range(n-k+1):
  P[i] = p[i:i+k].sum()

mp = p[np.argmax(P):np.argmax(P)+k]

ans = 0
for i in mp:
  j = i//2
  if i%2 == 0:
    ans += ((i+1)*j)/i
  else:
    ans += ((i+1)*j + j + 1)/i

print(ans)

Submission status: Time Limit Exceeded

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

ini = 0

for i in range(N-K+1):
    l = P[i:i+K]
    m = sum(l)
    if m > ini:
        ini = m

print(K + (ini-K)*0.5)

Submission status: Time Limit Exceeded

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

def main():
    N,K = map(int,input().split())
    p = list(map(DE,input().split()))
    ans = 0
    for i in range(N-K+1):
        ans = max(ans,sum(p[i:i+K]))
    print(ans)

if __name__ == '__main__':
    main()

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:
            a = ps[i-K+1:i+1]
            b = 1 / a  #[np.delete(a, i).prod() for i in range(K)]
            c = ps_means[i-K+1:i+1] * b
            sumval = np.sum(c)  #/ a.prod()
            if sumval > maxval:
                maxval = sumval
    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:
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = (((P*(P+1)/2))/P)
    kitaichi.append(kitai)
ans = 0
for j in range((n-k)+1):
    a = sum(kitaichi[j:j+k])
    if a > ans:
        ans = a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
numbers = input().split()
n = int(numbers[0])
k = int(numbers[1])

input = sys.stdin.readline
dices_input = input().split()
dices = [(int(i)+1)*0.5 for i in dices_input]

expected = [None] * (n-k+1)
for j in range(n-k+1):
    ex = 0
    for x in range(k):
        ex += dices[j + x]
    expected[j] = ex
print(max(expected))

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
    mel = mel + c/p[i]
    c = 0
  S.append(mel)
  mel = 0
  Max += 1
  min += 1

print(max(S))

Submission status: Time Limit Exceeded

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

gokei = 0

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

print(gokei)

Submission status: Time Limit Exceeded

Solution code:

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

ll = []
m = 0
for i in range(0, len(P)):
    lll = P[i:i + K]
    s = sum(lll)
    if m < s:
        m = s
        ll = lll

ans = 0
for x in ll:
    for i in range(1, x + 1):
        p = i / x
        ans += p

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))
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 m < j:
          m = j
          t = l[i:i+K]

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

Submission status: Time Limit Exceeded

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

m = p[0:K]
for i in range(1,N-K+1):
    if sum(m) < sum(p[i:K+i]):
        m = p[i:K+i]
e = np.array(m)
a = (1+e)/2
n = sum(a) 
print(n)

Submission status: Time Limit Exceeded

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

max = []
for i in range(N-K+1):
    #print(i)
    target = P[i:i+K]
    #print(target)
    if sum(max) < sum(target):
        max = target

#aprint(max)
ans = (sum(max) + K)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
count=0
index=[]
ans = 0

for i in range(len(p)-k+1):
    count = sum(p[i:k+i])
    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()))
ans = 0

for i in range(n-k+1):
    t = 0
    for j in range(k):
        t += p[i+j]
    else:
        if t > ans:
            ans = t

print((ans+k)/2)

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((sum(l[y:y+k]) + k)/2)

#print(z)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
count=0
for i in range(n-k+1):
  gouke = sum(p[i:i+k])
  if gouke>count:
    count=gouke
ans = (count+k)*0.5
print(ans)