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:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))
l = [] * total

tar2 = 0
calc_before = 0
calc_now = 0
for i in range(total+1-tar):
  for j in range(tar):
    calc_now += dice_array[i + j]
  if calc_before < calc_now:
    tar2 = i
    calc_before = calc_now
  calc_now = 0
  
sum = 0
for i in range(tar2, tar+tar2):
  cnt = 0
  for j in range(1, dice_array[i]+1):
    cnt += j
  sum += (cnt / dice_array[i])
  
print(sum)

Submission status: Time Limit Exceeded

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

list = 0
for i in range(N-K+1):
    p = pn[i:i+K]
    list = max(list, sum(p))

ans = (list+K)/2
print(ans)

Submission status: Time Limit Exceeded

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

psum = []
for i in range(N-K+1):
    psum.append(sum(p[i:i+K]))
print((max(psum)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import sys
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:
import numpy as np

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

max=0
for i in range(int(len(p)-K+1)):
    #print("i="+str(i))
    all=float(0)
    for j in range(i,i+int(K)):
        #print(((p[j]*(p[j]+1))/2)/p[j])
        all+=((p[j]*(p[j]+1))/2)/p[j]

    if max<all:
        max=all

print(max)

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(p[i:i+k])
l = []
for ls in lstp:
    num = 0
    for j in range(k):
        num  += 0.5*(ls[j]+1)
        l.append(num)
print("{:.10f}".format(max(l)))

Submission status: Time Limit Exceeded

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

l = list(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())
p = list(map(int, input().split()))
ans = 0
A = 0
for i in range(n-k+1):
    exp = sum(p[i:i+k])
    if ans < exp:
        ans = exp 
        A = (exp+k)/2
print(A)

Submission status: Time Limit Exceeded

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

N, K = map(int, input().split())
p_list = list(map(int, input().split()))
calc_expected_value_func = calc_expected_value
expected_value_p_list = list(map(calc_expected_value, p_list))
max_sum = 0
for i in range(0, N - K + 1):
    tmp_sum = sum(expected_value_p_list[i:K+i])
    if max_sum < tmp_sum:
        max_sum = tmp_sum
print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate

def e(dice):
    return sum([r / dice for r in range(1, dice+1)])

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

p_cum = [0] + list(accumulate(p))

ma = 0
ind = 0
for i in range(k, n+1):
    if ma < p_cum[i] - p_cum[i-k]:
        ma = p_cum[i] - p_cum[i-k]
        ind = i

x = p[ind-k:ind]

print(sum(e(d) for d in x))

Submission status: Time Limit Exceeded

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

# T[i]に1からiまでの合計値が入っている
# M[i]にiの目があるさいころの期待値が入っている
# T = [0]
# M = [0]
# for j in range(1,1001):
#     T.append(j + T[j-1])
#     K.append(T[j]/j)
# 計算すると(n+1)/2


# M = [0]
# for j in range(1,1001):
#     M.append((j+1)/2)
# # print(K)

# PP = []
# for k in P:
#     PP.append(M[k])
ANS = 0
for i in range(N-K+1):
    TEMP = sum(P[i:i+K])
    if TEMP > ANS:
        ANS = TEMP
print((ANS+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = []
kitaiti = 0
max_key = -1
for i in range(len(p)):
    sum_p = sum(p[i:i+k])
    if max_key <= sum_p:
        max_key = sum_p
        key = i
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:


n, k= [0] * 2
p = []

def format_input(filename = None):
	global n, k
	global p
	if filename == None:
		n, k = list(map(int, input().split()))
		p = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 2 * 10**5)
		k = rng(1, n)
		p = [rng(1, 10**3) for i in range(n)]

def get_answer():
	e = []
	for i in range(n - k + 1):
		e.append(sum(p[i:i+k]))
	e.sort()
	answer = float(e.pop() + k) / 2.0
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
for i in range(N-K+1):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count)
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)

Submission status: Time Limit Exceeded

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

li0 = [0]*(n-k+1)

for i in range(n-k+2):
  li0[i-1] = sum(li[i-1:i+k-1])

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

Submission status: Time Limit Exceeded

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

e = []

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print((ans+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#import time 
import numpy as np

#t1 = time.time()
N, K = map(int, input().split())
#P_list = [i for i in map(int, input().split())]

def func(a):
	a_list = [i/a for i in range(1, a+1)]
	return sum(a_list)

ALL_dice = [i for i in range(1, 1001)]
ALL_exp = list(map(func, ALL_dice))

#P_exp = list(map(func, P_list))

P_exp = [ALL_exp[i-1] for i in map(int, input().split())]

#A_list = []
#sum_K = 0
#t1 = time.time()
A_list = np.array([sum(P_exp[i:i+K]) for i in range(N-K+1)])
"""
for i in range(N-K+1):
	for j in range(K):
		sum_K += P_exp[i+j]

	A_list.append(sum_K)
	sum_K = 0
"""
print(np.max(A_list))
#print(A_list)
#t2 = time.time()
#print(t2-t1)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = [(int(j) + 1) / 2 for j in input().split()]

li2 = sorted([sum(li[m:m+k]) for m in range(0, len(li) - k + 1, 1)], reverse=True)

print(li2[0])

Submission status: Time Limit Exceeded

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

ex_value = 0
max_ex_value = 0
for i in range(0,int(n-k+1)):
  ex_value = 0
  for j in range(0, k):
    x = p_list[i+j]           
    ex_value += (x+1)/2
  if ex_value >= max_ex_value:
    max_ex_value = ex_value
               
print(max_ex_value)

Submission status: Time Limit Exceeded

Solution code:
a = [int(b) for b in input().split()]
l = input().split()
l = [int(n) for n in l]
b = a[0] - a[1]+1

ret = [0.5*(sum(l[i:i+a[1]])+a[1]) for i in range(b)]

print(max(ret))

Submission status: Time Limit Exceeded

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

kitai = [None]*(1001)
for i in range(1, 1001):
    kitai[i] = (0.5*i*(i+1))/i

ruiseki = [None]*(N-K+1)
for i in range(0, N-K+1):
    ruiseki[i] = sum(P[i:i+K])

ind = np.array(ruiseki).argmax()
temp = P[ind:ind+K]
ans = 0
for t in temp:
    ans+=kitai[t]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def ex(n):
    return sum(list(range(1, n+1))) / n

# main
N, K = mis()
p = lmis()

ex_max = 0
for i in range(N-K+1):
    ex_temp = 0
    for j in range(i, i+K):
        ex_temp += ex(p[j])

    if ex_max < ex_temp:
        ex_max = ex_temp

print(ex_max)

Submission status: Time Limit Exceeded

Solution code:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = (1+pi)/2
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        tmp -= arr[0]
        arr.pop(0)

print(max)

Submission status: Time Limit Exceeded

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

# リストの値を期待値に変換
for i in range(n):
    v_n[i] = (p_n[i] + 1) / 2

s = 0
max_s = 0

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

    if s > max_s:
        max_s = s

print(max_s)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    max_value = 0
    for i in range(N - K + 1):
        compare_value = sum(p[i : i + K])

        if max_value < compare_value:
            max_value = max(max_value, compare_value)
            index_first = i
        else:
            pass
    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        idm = (p[index_first + j] / 2) * (1 + p[index_first + j])
        idm /= p[index_first + j]
        result += idm
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

p_list = [ int(p) for p in input().split(' ')]

e_max = sum(p_list[:k])
p_list.pop(0)

for i in range(n - k):
    temp = sum(p_list[:k])
    if e_max < temp:
        e_max = temp
    p_list.pop(0)

print(float(e_max)/2 + float(k)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
P = np.array([int(i) for i in input().split()])
ev = np.zeros(N)
for i, p in enumerate(P):
    ev[i] = (p / 2.0 * (p + 1.0)) / p
ev_sums = np.zeros(N - K + 1)
for i in range(len(ev_sums)):
    ev_sums[i] = np.sum(ev[i:i+K])

print(np.max(ev_sums))

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):
  if ans < sum(p[i:i+k]):
    ans = sum(p[i:i+k])
    ans_p = p[i:i+k]
ans_ = 0
for i in ans_p:
  ans_ += sum(range(i+1))/i
print(ans_)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

kitai = []
for i in range(n):
    tmp = 0
    for j in range(1, p[i] + 1):
        tmp += j
    kitai.append(tmp / p[i])

ans = 0
for i in range(n - k + 1):
    tmp2 = 0
    for j in range(i, i + k):
        #print(j)
        #print(kitai[j])
        tmp2 += kitai[j]
    #print(tmp2)
    if ans < tmp2:
        ans = tmp2
print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
  
ans = []
for i in range(N - (K - 1)):
  a = p[i: i + K]
  if sum(a) > sum(ans):
    ans = a


print((sum(ans) + K) /2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max = 0
ite = N - K + 1
max = 0
base = sum(p[0:K])
for i in range(ite):
    S = 0
    for j in range(i, i+K):
        S += p[j]
    if S > max:
        max = S
        index = i

E = [None]*K
for i in range(K):
    E[i] = sum(range(1, p[index+i]+1))/p[index+i]
print(sum(E))

Submission status: Time Limit Exceeded

Solution code:
def sigma(n):
    a = 0
    for i in range(1, n + 1):
        a += i
    return a


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

    a = []
    for p in P:
        a.append(sigma(p) / p)

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

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

subs = [p[ind:ind+k] for ind in range(n-k+1)]
sums = [sum(elm) for elm in subs]
max_val = float(max(sums))
k = float(k)
print(max_val/2+k/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
maxsumP = -1
resP = []
for i in range(N-K+1):
  PP = P[i:K+i]
  mp = sum(PP)
  if maxsumP < mp:
    resP = PP
    maxsumP = mp
res = 0
dp = {}
for p in resP:
  if p in dp:
    res += dp[p]
  else:
  	dp[p] = sum(range(p+1))/float(p)
  	res += dp[p]
    
print(res)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
sum = 0
max = 0
index = 0
value = 0.000000000000

for i in range(n - k + 1):
    sum = 0
    for j in range(k):
        sum += p_list[i + j]
    if sum > max:
        max = sum
        index = i

for i in range(k):
    for j in range(p_list[index + i]):
        value += (j + 1) / p_list[index + i]

print(value)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
m=h=0
for i in range(n-k+1):
	s=0
	for j in range(i,i+k):s+=p[j]
	if s>m:m=s;h=i
print(sum((sum(range(1,1+p[i]))/p[i] for i in range(h,h+k))))

Submission status: Time Limit Exceeded

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

import numpy as np

n, k = na()
p = na()

ans = 0.0
for i in range(n - k + 1):
    s = 0.0
    for j in range(k):
        a = (p[i + j] * (p[i + j] + 1) // 2) * (1 / p[i + j])
        s += a
    ans = max(ans, s)

print(ans)

Submission status: Time Limit Exceeded

Solution code:

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    ans.pop(0)
    ans.append(V[n])
    max_v = max(max_v, sum(ans))
print(max_v)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N, K = int(NK[0]), int(NK[1])
lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(lambda x: (x+1)/2, lis_p))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Submission status: Time Limit Exceeded

Solution code:
n,k = input().split()
n = int(n)
k = int(k)
nums = [float(i)/2+0.5 for i in input().split()]
now_list = [sum(nums[i:i+k]) for i in range(n-k+1)]
print(max(now_list))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

def process(c,m):
    return np.convolve(0.5*(candidates+1), np.ones(m))

n, m = map(int, input().split())

candidates = np.array(list(map(int, input().split())))
s = process(candidates, m)
print(s.max())

Submission status: Time Limit Exceeded

Solution code:
from itertools import count, islice

n, k = tuple(map(int, input().split()))
dice = list(map(int, input().split()))
p_dice = [sum(islice(count(1), e)) / e for e in dice]
print(max([sum(p_dice[i:i+k]) for i in range(0, n - k + 1)]))

Submission status: Time Limit Exceeded

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

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
ls.append([ans,0])

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    ls.append([ans,i+1])

ls = sorted(ls,reverse=True)

ans = 0
for i in range(k):
    for j in range(p[ls[0][1]+i]):
        ans += (1/p[ls[0][1]+i]*(j+1))
    
print(ans)

Submission status: Time Limit Exceeded

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

def kitaiti(n , k , p):

    ans = 0
    kitai = [0]*n

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n - k + 1):
        count = 0
        for w in range(i , i + k):
            count += kitai[w]

        ans = max(ans , count)

    return ans

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

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

res=[]

res.append((sum(np.arange(1,p[0]+1)))/p[0])

for i in range(1,N):
    res.append(res[i-1]+(np.sum(np.arange(1,p[i]+1)))/p[i])
ans=res[K-1]

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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


def hoge(ls):
    e_value = 0
    for l in ls:
        e_value += np.arange(1, l+1).sum() / l
    return e_value


ans = 0
for i in range(N-K+1):
    tmp = nums[i:i + K]
    max_tmp = hoge(tmp)
    if max_tmp > ans:
        ans = max_tmp
print(ans)

Submission status: Time Limit Exceeded

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

tmp = [sum(list(range(1,i+1)))/i for i in P]

res = 0.0
for k in list(range(N)):
    choise = tmp[k:K+k]
    if len(choise) == K:
        res1 = sum(choise)
        if res < res1:
            res = res1

print(res)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
EV_p_list = [0] * len(p_list)

EV_list = [0] * 1000

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

for i in range(len(p_list)):
  index = p_list[i]
  EV_p_list[i] = EV_list[index - 1]

max_EV = 0
for i in range(N - K + 1):
  tmp = 0
  for j in range(K):
    tmp += EV_p_list[i + j]
  
  if tmp >= max_EV:
    max_EV = tmp

print(max_EV)

Submission status: Time Limit Exceeded

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

import math

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

def expected(x):
    s = 0
    if x % 2 == 1:
        s = x * math.ceil(x / 2)
    else:
        s = (x + 1) * (x / 2)

    return s / x

b = {}
mx = 0

for i in range(N - K + 1):
    s = 0
    for j in range(K):
        k = i + j
        if not P[k] in b:
            b[P[k]] = expected(P[k])
        s += b[P[k]]
    mx = max(mx, s)

print(mx)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K = map(int, input().split())
P = list(map(int, input().split()))
sums = []
for i in range(N - K + 1):
  sums.append(sum(P[i:i + K]))
print(((np.max(np.array(sums))) + K) / 2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
souwa=0
for i in range(q[0]-q[1]+1):
  k=0
  for j in range(q[1]):
    k+=w[i+j]
  if a<k:
    a=k
    memo=i
for p in range(q[1]):
  souwa+=(w[memo+p]+1)/2
print(souwa)

Submission status: Time Limit Exceeded

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

max_nums = 0
for idx in range(0, len(nums)-K+1):
    tmp = nums[idx:idx+K]
    sums = sum(tmp)
    if sum(tmp) > max_nums:
        max_nums = sums
        max_list = tmp

kitai = 0

for num in max_list:
    kitai += (num+1)/2

print(kitai)

Submission status: Time Limit Exceeded

Solution code:
t = input().split(" ")

N = int(t[0])
K = int(t[1])

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

for i in range(len(p)):
    #a = list(range(1,p[i]+1))
    #print(a)
    p[i] = sum(list(range(1,p[i]+1)))/p[i]

ans = 0
a =0
for i in range(N):
    

    a += p[i]
    
    if i >= K-1:
        
        if i >= K:
            a += -(p[i-K])
        if a > ans:
            ans = a

print(ans)

Submission status: Time Limit Exceeded

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

nums = []

for i in range(N - K + 1):
    num = [p[i] for i in range(i, i + K)]
    nums.append([i, sum(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:
import sys
def input():
    return sys.stdin.readline()[:-1]
N, K = map(int, input().split())
p = list(map(int, input().split()))

ppp=[]
for i in range(N-K+1):
  ppp.append(sum(p[i:i+K]))

i =ppp.index(max(ppp))

tmp = p[i:i+K]

print((sum(tmp)+K)*0.5 )

Submission status: Time Limit Exceeded

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

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

print((k+a)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
d = input().split()
d = [int(i) for i in d]
tmp = 0
result = 0

for l in range(1,n-k+2):
  tmp_res = 0
  for j in range(l,l+k):
    for i in range(1,d[j-1]+1):
      tmp += i
    tmp = tmp/float(d[j-1])
    tmp_res += tmp
    tmp = 0
  if tmp_res >= result:
    result = tmp_res

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
items = []
for i in range(n):
  items += sum(l[i:i+k]),
print((max(items)+k)/2)

Submission status: Time Limit Exceeded

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

c = [sum(b[i:i+a[1]]) for i in range(0, len(b) - a[1] + 1)]
d = c.index(max(c))
e = b[d:d+a[1]]
f = sum([sum(range(1, d + 1)) / d for d in e])

print(f)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def e(dice):
    return sum([r / dice for r in range(1, dice+1)])

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

p_cum = [0] + list(np.cumsum(p))

ma = 0
ind = 0
for i in range(k, n+1):
    if ma < p_cum[i] - p_cum[i-k]:
        ma = p_cum[i] - p_cum[i-k]
        ind = i


x = p[ind-k:ind]

print(sum(e(d) for d in x))

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 = 0.
  for item in _list[start:start+_k]:
    ans += (item+1) / 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())
ps = list(map(int, input().split()))
E = lambda x: x if x==1 else (x+1)*(x/2)/x
ans = (0,0)
for i in range(N-(K-1)):
  s = sum(ps[i:i+K])
  ans = (i,s) if ans[1] < s else ans
print(sum(map(E, ps[ans[0]:ans[0]+K])))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    if sum(p[i:i+k])>=x:
        x = sum(p[i:i+k])
        lis = p[i:i+k]
ans = sum(lis)/2 + 0.5*k 
print(ans)

Submission status: Time Limit Exceeded

Solution code:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


def calc_expected(pi):
    return (1+pi)/2


max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = calc_expected(pi)
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        tmp -= arr[0]
        arr.pop(0)

print(max)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

nk = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))
n = nk[0]
k = nk[1]

x = (1+p)/2

res = 0
for i in range(n-k+1):
    if sum(x[i:i+k]) > res:
        res = sum(x[i:i+k])

print(res)

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(' ')]
ret = []
for i in range(N): # 0 ~ 4
    sums = 0;
    if i+K > N: break;
    for j in range(i, i+K):
        sums += calc(_p[j])
    ret += [sums]

print(max(ret))

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

E = (P + 1) / 2

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n, k = map(int, input().split(" "))
p_list = list(map(int, input().split(" ")))
max = 0
ans = 0
for i in range(n-(k-1)):
    sum_list = sum(p_list[i:i+k])
    if max < sum_list:
        max = 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)