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 = list(map(int, input().split()))
# 期待値
E = [(p+1)/2 for p in P]
#print(E)
# 隣接K個の和
ans = 0
for i in range(K, N+1):
    tmp_e = sum(E[i-K: i])
    #print(i, tmp_e)
    ans = max(ans, tmp_e)
print(ans)

Submission status: Time Limit Exceeded

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

i = 0
max = 0
expect_list = []
for p in p_list:
  expect_list.append((p + 1) / 2)
  
while i < n - (k - 1):
  sum_ex = sum(expect_list[i:i + k])
  if max < sum_ex:
    max = sum_ex
  i += 1

print(max)

Submission status: Time Limit Exceeded

Solution code:
class SegmentTree:
    seg_len = 1
    node = []
    def __init__(self, n):
        while self.seg_len < n:
            self.seg_len <<= 1
        self.node = [ 0 for _ in range(self.seg_len*2) ]

    def add(self, idx, v):
        idx += self.seg_len
        self.node[idx] += v
        while True:
            idx //= 2
            if idx == 0:
                break
            self.node[idx] = self.node[idx*2] + self.node[idx*2+1]

    def sum(self, l, r):
        l += self.seg_len
        r += self.seg_len
        ret = 0
        while l < r:
            if l & 1 == 1:
                ret += self.node[l]
                l += 1
            if r & 1 == 1:
                ret += self.node[r-1]
                r -= 1
            l //= 2; r //= 2;
        return ret


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

seg_tree = SegmentTree(n)
for i in range(n):
    seg_tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, seg_tree.sum(i, i+k))

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K =map(int, input().split())
lst=list(map(int, input().split()))
mx=0
for i in range(0, N-K+1):
	S=sum(lst[i:i+K])
	if mx<S:
		mx=S
print((mx+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N, K =map(int, input().split())
lst=list(map(int, input().split()))
mx=0
for i in range(0, N-K+1):
	S=sum(lst[i:i+K])
	if mx<S:
		mx=S
print((mx+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N, K =map(int, input().split())
lst=list(map(int, input().split()))
new_lst=[]
mx=0
for i in range(0, N-K+1):
	if mx<sum(lst[i:i+K]):
		mx=sum(lst[i:i+K])

print((mx+K)/2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split())) #サイコロの最大値

# 期待値の配列を作る
e = []
max_m = 0
f = []
e = [(1+p[i])/2  for i in range(n)]
for j in range(n-k+1):
    m = sum(e[j:j+k])
    max_m = max(max_m, m)
    # if max_m < m:
    #     max_m = m

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_3
# CreatedDate:  2020-03-23 01:25:11 +0900
# LastModified: 2020-03-23 01:38:31 +0900
#


import os
import sys


def main():
    N, K = map( int, input().split())
    P = list(map(int,input().split()))
#    print(P)
    manman=0
    for i in range(N-K+1):
        if manman<sum(P[i:(i+K)]):
            manman=sum(P[i:(i+K)])
    print((manman+K)/2)
    


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(lambda x: int(x), input().split()))
P_array = list(map(lambda x: int(x), input().split()))

goukei = 0
tochu_array = []

for n in range(N-K+1):
    tochu_array.append(sum(P_array[n:n+K]))

for n in range(K):
    dice = range(1,P_array[tochu_array.index(max(tochu_array))+n] + 1)
    ex = 0
    p = 1 / len(dice)
    for x in dice:
        px = p * x
        ex += px
    goukei+=ex

print(goukei)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(lambda x: int(x), input().split()))
P_array = list(map(lambda x: int(x), input().split()))

goukei_array = []

for n in range(N-K+1):
    goukei_array.append(0)
    for m in range(K):
        dice = range(1, P_array[n+m]+1)
        ex = 0
        p = 1 / len(dice)
        for x in dice:
            px = p * x
            ex += px
        goukei_array[n]+=ex

print(max(goukei_array))

Submission status: Time Limit Exceeded

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

e = [0] * 1001
e[1] = 1.0
for i in range(2, 1001):
    e[i] = e[i-1] + 0.5

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

Submission status: Time Limit Exceeded

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

# estP = [-1]
def est(i):
    return 1.0 + (i - 1) * 0.5
# for i in range(1, 1001):
# print(i, sum([j * 1.0 / i for j in range(1, i + 1)]))
# estP.append(sum([j * 1.0 / i for j in range(1, i + 1)]))
# print(i, 1.0 + (i - 1) * 0.5)
# # print(estP)

m = -1.0
for i in range(N - K + 1):
    vi = sum([est(P[j]) for j in range(i, i + K)])
    m = max(vi, m)
print(m)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

ans = 0
answer = 0

for i in range(n-k+1):
    total = sum(pp[i:i+k])
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    answer += (1+pp[num+n])/2

print(answer)

Submission status: Time Limit Exceeded

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

ans = 0
answer = 0

for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += pp[j]
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    answer += (1+pp[num+n])/2

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ls = []
ans = 0
answer = 0

for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += pp[j]
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    ls.append(pp[num+n])

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

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans = 0

# p=1とp=2の期待値は変わらないことに注意
for i in range(n-k+1):
    total = 0
    for j in range(k):
        j += i
        total += sum([int(n) for n in range(1, pp[j]+1)])/pp[j]
    ans = max(ans, total)

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

Submission status: Time Limit Exceeded

Solution code:
#154_D
n, k = map(int, input().split())
p = [(int(x)+1) / 2 for x 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:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ll = [x / 2 * (x + 1) / x for x in ret_lst]
print(sum(ll))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ll = [sum(range(1, x + 1)) / x for x in ret_lst]
print(sum(ll))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ret = 0
for x in ret_lst:
    ret += sum(range(1, x + 1)) / x
print(ret)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
n = 0
ret_lst = []
for i in range(len(lst) - K + 1):
    if n < sum(lst[i : i + K]):
        n = sum(lst[i : i + K])
        ret_lst = lst[i : i + K]

ret = 0
for x in ret_lst:
    ret += sum(range(1, x + 1)) / x
print(ret)

Submission status: Time Limit Exceeded

Solution code:
#累積和の利用！！！！！！！！
from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int,input().split()))

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

for i in range(len(p)):
    p[i] = expect_dice(p[i])
    
p = [0] + p
p = list(accumulate(p))

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

Submission status: Time Limit Exceeded

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

def expect_dice(n):
    s = 0
    for i in range(1,n+1):
        s += i
    return s/n 
for i in range(len(p)):
    p[i] = expect_dice(p[i])
    
p = [0] + p
p = list(accumulate(p))

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

Submission status: Time Limit Exceeded

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

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

sum_cnt = []

for i in range(len(p)-k+1):
    out = 0
    for j in range(i,i+k):
        out += p[j]
    sum_cnt.append(out)
sum_cnt = np.array(sum_cnt)
result = 0
for k in range(k):
    result += expect_dice(p[np.argmax(sum_cnt)+k])

print(result)

Submission status: Time Limit Exceeded

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

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

result = []

for i in range(len(p)-k+1):
    out = 0
    for j in range(i,i+k):
        out += expect_dice(p[j])
    result.append(out)
    
print(max(result))

Submission status: Time Limit Exceeded

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

s = []

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

m = max(s)/2 + k/2

print(m)

Submission status: Time Limit Exceeded

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

max = 0

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


ave = 0
for i in range(m, m+k):
    ave += (p[i] + 1)/2

print(ave)

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

q = []
sm = []

for value in p:
    q.append((value + 1) / 2)

for i in range(N-K+1):
    sm.append(sum(q[i:i+K]))

print(max(sm))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l2 = [0 for _ in range(k)]
for i in range(n-k+1):
  if s < sum(l[i:i+k]):
    s = sum(l[i:i+k])
    for j in range(k):
      l2[j] = i + j
ans = 0
for i in range(k):
  ans += (1+l[l2[i]])/2
print("{:.8}".format(ans))

Submission status: Time Limit Exceeded

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

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

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)

Submission status: Time Limit Exceeded

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

lambda x:x+1/2
ans=0
tmp=0
for i in range(n-k+1):
    if tmp < sum(s[i:i+k]):
        tmp = sum(s[i:i+k])
        kukan = [i,i+k]

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
s=list(map(int,input().split()))
e=[0]*n
e_table=[0]*1000
tmp=0
for i in range(1000):
    tmp+=(i+1)
    e_table[i] = tmp/(i+1)


e = list(map(lambda x:e_table[x-1],s))

ans=0

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
s=list(map(int,input().split()))
e=[0]*n
e_table=[0]*1000
tmp=0
for i in range(1000):
    tmp+=(i+1)
    e_table[i] = tmp/(i+1)

for i,p in enumerate(s):
    e[i] = e_table[p-1]

ans=0

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

Submission status: Time Limit Exceeded

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

pp_ex = list(map(lambda p: (p + 1) / 2, pp))

max_ex = 0
# for i in range(k):
#     max_ex += pp_ex[i]

for i in range(0, n - k + 1):
    ex = 0
    for j in range(k):
        ex += pp_ex[i + j]
    if max_ex < ex:
        max_ex = ex

print(max_ex)

Submission status: Time Limit Exceeded

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

pp_ex = list(map(lambda p: (p * (p + 1) / 2) / p, pp))

max_ex = 0
for i in range(n - k + 1):
    ex = 0
    for j in range(k):
        ex += pp_ex[i + j]
    if max_ex < ex:
        max_ex = ex

print(max_ex)

Submission status: Time Limit Exceeded

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

max_ex = 0
for i in range(n - k + 1):
    ex = 0
    for j in range(k):
        p = pp[i + j]
        ex += (p * (p + 1) / 2) / p
    if max_ex < ex:
        max_ex = ex

print(max_ex)

Submission status: Time Limit Exceeded

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


def solve(N: int, K: int, p: "List[int]"):
    p2 = [(i + 1) / 2 for i in p]
    m = -1
    for i in range(N - (K - 1)):
        s = 0
        for j in range(K):
            s += p2[i + j]
        m = max(m, s)
    print(m)


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



max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1
print(sum_odds)

Submission status: Time Limit Exceeded

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

dice_cumsum = [0]*200001
dice_cumsum[1] = 1

for i in range(2,200001):
    dice_cumsum[i] = dice_cumsum[i-1]+i


max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += dice_cumsum[dice[max_i+i]]/dice[max_i+i]
    
print(sum_odds)

Submission status: Time Limit Exceeded

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

odds = list(map(lambda x: 0.5*(x-1)+1,dice))

max_n = 0
for i in range(n-k+1):
    sum_odds = sum(odds[i:k+i])
    if sum_odds > max_n:
        max_n = sum_odds


        
print(max_n)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
exps = [
    float(sum(range(1, p + 1))) / float(p)
    for p in map(int, input().split())
]
ans = 0
for i in range(N - K + 1):
    exp = sum([e for e in exps[i:i+K]])
    if ans < exp:
        ans = exp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

P = []
S = []
N, K = map(int, input().split())
P = input().split(' ')
P = [int(t) for t in P]
for i in range(N-K+1):
	sum = 0
	for k in range(K):
		sum = sum + P[i+k]
	S.append(sum)
id = S.index(max(S))

ex = 0
for k in range(K):
	idk = id + k
	for p in range(P[idk]):
		ex = ex + (p + 1) * (1 / P[idk])
ex = math.floor(ex * 10 ** 6) / (10 ** 6)
print(ex)

Submission status: Time Limit Exceeded

Solution code:
P = []
S = []
N, K = map(int, input().split())
P = input().split(' ')
P = [int(t) for t in P]
for i in range(N-K+1):
	sum = 0
	for k in range(K):
		sum = sum + P[i+k]
	S.append(sum)
id = S.index(max(S))

ex = 0
for k in range(K):
	idk = id + k
	for p in range(P[idk]):
		ex = ex + (p + 1) * (1 / P[idk])
print(ex)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
	sum = 0
	for k in range(K):
		sum = sum + int(P[i+k])
	S.append(sum)
id = S.index(max(S))

ex = 0
for k in range(K):
	idk = id + k
	for p in range(int(P[idk])):
		ex = ex + (p + 1) * (1 / int(P[idk]))
print(ex)

Submission status: Time Limit Exceeded

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

    #p_list.sort(reverse=True)
    #print(p_list)

    ans = 0
    if k == 1:
        p_list.sort(reverse=True)
        ans = (p_list[0]+1)*0.5
    else:
        for j in range(n-(k-1)):
            ans_tmp = 0
            for i in range(k):
                ans_tmp += (p_list[i+j]+1)*0.5
            if ans_tmp >= ans:
                ans = ans_tmp

    print(ans)

    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
def goukei(i):
    return sum(hopes[:i+1])
numbers=[]
for a in range(N):
    numbers.append(goukei(a))
answers=[]
for a in range(N-K):
    i=numbers[a+K]-numbers[a]
    answers.append(i)
answers.append(numbers[K-1])
print(max(answers))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
def goukei(i):
    S=0
    for a in range(i):
        S+=hopes[a]
    return S
numbers=[]
for a in range(N-K+1):
    number=goukei(a+K)-goukei(a)
    numbers.append(number)
print(max(numbers))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=input().split()
def hope(a):
    numbers=[int(b) for b in range(1,a+1)]
    goukei=sum(numbers)
    return goukei/a
P=[int(z) for z in p]
numbers=[]
for y in range(N-K+1):
    w=0
    for x in range(K):
        w+=P[x+y]
    numbers.append(w)
place=numbers.index(max(numbers))
answer=0
for q in range(K):
    answer+=hope(P[place+q])
print(answer)

Submission status: Time Limit Exceeded

Solution code:

import math

M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
q=0

for i in range(N-K+1):
   for j in range(K):
       a=P[i+j]
       q=q+M[a]
   Q.append(q)
   q=0

print(max(Q))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    Sum = 0
    for i in range(pi+1):
        Sum += i
    ev.append(Sum / pi)

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    # print(i)

print(ans)
# print(ev)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    Sum = 0
    for i in range(pi+1):
        Sum += i
    ev.append(Sum / pi)

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

print(ans)
# print(ev)

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

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

A = []

for i in range(K-1, N):
    A.append(sum(P[i-(K-1):i+1]))

print(0.5*(K+max(A)))

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

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

A = [0] * K

for i in range(K-1, N):
    if sum(P[i-(K-1):i+1])>sum(A):
        A = P[i-(K-1):i+1]

ans = 0

for a in A:
    ans += 0.5*(1+a)

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
x = 0
for i in range(a-b+1):
  #print(d[i:i+b])
  if ans < sum(d[i:i+b]):
    ans = sum(d[i:i+b])
    x = i
  
  
d2 = [(i+1)/2 for i in d[x:x+b]]

print(sum(d2))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
d2 = [(i+1)/2 for i in d]

ans = 0
for i in range(a-b+1):
  ans = max([ans,sum(d2[i:i+b])])
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = map(int, input().split())
p_e = [ (x + 1) * 0.5 for x in p]
e_sum = [sum(p_e[i:i+k]) for i in range(n - k + 1)]
print(max(e_sum))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = map(int, input().split())
p_e = list(map(lambda x: (x + 1)* 0.5, p))

e_sum = [sum(p_e[i:i+k]) for i in range(n - k + 1)]
print(max(e_sum))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = map(int, input().split())
p_e = list(map(lambda x: (x + 1)* 0.5, p))

max_e = -1
for i in range(n - k + 1):
    v = sum(p_e[i:i+k])
    if max_e < v:
        max_e = v
print(max_e)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = map(int, input().split())
p_e = list(map(lambda x: (x + 1)* 0.5, p))

max_e = -1
for i in range(n - k + 1):
    v = sum([p_e_j for p_e_j in p_e[i:i+k]])
    if max_e < v:
        max_e = v
print(max_e)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = map(int, input().split())
p_e = list(map(lambda x: sum([i for i in range(1, x+1)]) / x, p))

max_e = -1
for i in range(n - k + 1):
    v = sum([p_e_j for p_e_j in p_e[i:i+k]])
    if max_e < v:
        max_e = v
print(max_e)

Submission status: Time Limit Exceeded

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


def expected(n):
    return (1+n)/2

p=list(map(expected,p))
for i in range(N-K+1):
    sigmap=0
    for j in range(K):
        sigmap+=p[i+j]
    maxexp=max(sigmap,maxexp)
print(maxexp)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
from decimal import Decimal

n, k = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x: Fraction(x+1)/2, p))

cur = sum(p[:k])
res = cur

for i in range(k, n):
    cur += p[i] - p[i-k]
    res = max(res, cur)

d = Decimal(res.numerator) / Decimal(res.denominator)
print(d)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
all_num, select_num = map(int, input().split())
dice = [int(a) for a in input().split()]
max_sum = 0

for i in range(all_num - (select_num - 1)):
    if i == 0 or dice[i + select_num -1] > dice[i - 1]:
        this_sum = sum(dice[i:(i + select_num)])
        if this_sum > max_sum:
            max_sum = this_sum
    else:
        pass

print((max_sum + select_num) * 0.5)

Submission status: Time Limit Exceeded

Solution code:
all_num, select_num = map(int, input().split())
dice = [int(a) for a in input().split()]
max_sum = 0

for i in range(all_num - (select_num - 1)):
    this_sum = sum(dice[i:(i + select_num)])
 
    if this_sum > max_sum:
        max_sum = this_sum

print((max_sum + select_num) * 0.5)

Submission status: Time Limit Exceeded

Solution code:
all_num, select_num = map(int, input().split())
dice = [int(a) for a in input().split()]
max_sum = 0

for i in range(all_num - (select_num - 1)):
    #this_sum = 0
    select_list = []
    for s in range(select_num):
        #this_sum += dice[i+s]
        select_list.append(dice[i+s])

    this_sum = sum(select_list)
 
    if this_sum > max_sum:
        max_sum = this_sum

print((max_sum + select_num) * 0.5)

Submission status: Time Limit Exceeded

Solution code:
all_num, select_num = map(int, input().split())
dice = [int(a) for a in input().split()]
max_sum = 0

for i in range(all_num - (select_num - 1)):
    this_sum = 0
    for s in range(select_num):
        this_sum += dice[i+s]
 
    if this_sum > max_sum:
        max_sum = this_sum

print((max_sum + select_num) * 0.5)

Submission status: Time Limit Exceeded

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

J = []
J = [0] * N
for i in range(N):
    J[i] = sum(range(1, P[i] + 1)) / P[i]

A = []
A = [0] * N
for i in range(N):
    A[i] += sum(J[i: i + K])

print(max(A))

Submission status: Time Limit Exceeded

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

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

def S(i):
    S = 0
    for j in range(i):
        S += E[j]
    return S

expects = []
for j in range(N-K+1):
    expects.append(S(j+K) - S(j))

print(max(expects))

Submission status: Time Limit Exceeded

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

def expect(p):
    return sum(range(1,p+1))/p

sums = []
for i in range(N-K+1):
    expect_sum = 0
    for j in range(K):
        expect_sum += expect(P[i+j])
    sums.append(expect_sum)

print(max(sums))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
dice_list = [int(i) for i in input().split()]
wa_list = [0]
for dice in dice_list :
    prob = 0
    for i in range(dice) :
        prob += (i+1) * (1/(dice))
    wa_list.append(wa_list[-1] + prob)

max_p = -1
for i in range(N-K+1) :
    p = wa_list[i+K] - wa_list[i]
    if (max_p < p) :
        max_p = p

print(max_p)

Submission status: Time Limit Exceeded

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


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

ans_index = 0
max_sum = 0
for i in range(len(dices) - K + 1):
    # summation = 0
    # for j in range(K):
    #     summation += dices[i + j]
    summation = sum(dices[i:i + K])
    if max_sum < summation:
        max_sum = summation
        ans_index = i

ans = 0
for dice in dices[ans_index:ans_index + K]:
    ans += sum(list(range(1, dice + 1))) / dice
print(ans)

Submission status: Time Limit Exceeded

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

ans_index = 0
max_sum = 0
for i in range(len(dices) - K + 1):
    summation = 0
    for j in range(K):
        summation += dices[i + j]
    if max_sum < summation:
        max_sum = summation
        ans_index = i

ans = 0
for dice in dices[ans_index:ans_index + K]:
    ans += sum(list(range(1, dice + 1))) / dice
print(ans)

Submission status: Time Limit Exceeded

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

def sm(lst, j, k):
  res = 0
  for i in range(j, j+k):
    res += lst[i]
  return res

def max(lst, k):
  res = sm(lst, 0, k)
  for i in range(1, N-k+1):
    if lst[i-1] < lst[i+k-1]:
      if res < sm(lst, i, k):
        res = sm(lst, i, k)
  res = (res+k)/2
  return res

print(max(List, K))

Submission status: Time Limit Exceeded

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

def sm(lst, j, k):
  res = 0
  for i in range(j, j+k):
    res += lst[i]
  return res

def max(lst, k):
  res = 0
  for i in range(N-k+1):
    if res < sm(lst, i, k):
      res = sm(lst, i, k)
  res = (res+k)/2
  return res

print(max(List, K))

Submission status: Time Limit Exceeded

Solution code:
i = list(map(int, input().split()))
N = i[0]
K = i[1]

p = list(map(int, input().split()))
max_s = 0
s_current = 0

for i in range(N - K + 1):
    if i == 0:
        for j in range(K):
            p_list = [p[k] for k in range(K)]
            max_s = sum(p_list)
            s_current = max_s
    else:
        s_current = s_current - p[i - 1] + p[i + K - 1]
        if s_current > max_s:
            max_s = s_current
    
ans = (max_s + K) / 2.0
print(ans)

Submission status: Time Limit Exceeded

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