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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def expected_value(x):
    return 0.5*(x+1)

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

candidates = map(int, input().split())
candidates = list(map(expected_value, candidates))
s = np.convolve(candidates, np.ones(m), mode='valid')
print(s.max())

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
saidai = 0
for i in range(n-k+1):
    wa = 0
    for j in range(i, i+k):
        wa += p[j]
    if wa > saidai:
        saidai = wa
kitai = (1/2)*(k+saidai)
print(str(kitai))

Submission status: Time Limit Exceeded

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

maxpair = (-1,-1)

for i in range(N-K+1):
    ksum = sum(PP[i:i+(K)])
    if ksum > maxpair[1]:
        maxpair = (i,ksum)
        
mp = maxpair[0]        
maxrange = PP[mp:(mp+K)]

esum = 0
for m in maxrange:
    esum += (m+1)/2
    
print(esum)

Submission status: Time Limit Exceeded

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

max_num = 0
max_left_n = 0
for left_n in range(N-K+1):
    new_max_num = sum(p[left_n:left_n+K])
    if new_max_num > max_num:
        max_num = new_max_num
        max_left_n = left_n

ans = 0.0
for n in range(max_left_n, max_left_n+K):
    ans += (1 + p[n]) / 2
    # print((1 + p[n]) / 2)
    # print(p[n])
    # print(ans)

# print(max_left_n)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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)
ansum = np.array([])
for i  in range(len(p)-k+1):
    pk = (p[i:i+k]+1)/2
    ansum = np.append(ansum, sum(pk))

print(max(ansum))

Submission status: Time Limit Exceeded

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

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

expected = 0
for p in P[m_index:m_index+K]:
    expected += sum(list(range(1, p+1)))/p
print(expected)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

keep_val = 0
check = 0
for i in range(n-k+1):
    ss = sum(p[i:i+k])
    if keep_val < ss:
        check = i
        keep_val = ss

#print(p[check:check+k])

ans = 0
for i in p[check:check+k]:
    ans += (i+1)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(a):
    sum = 0
    for i in range(a):
        sum += i+1
    return sum / a

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]
lis = [0] * n

for i in range(n):
    lis[i] = kitaichi(p[i])

val = 0
ans = 0

for i in range(0, n-k+1):
    val = 0
    for j in range(k):
        val += lis[i+j]
    ans = max(ans, val)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=[int(i) for i in input().split(" ")]
p=[int(i) for i in input().split(" ")]

def Ex(p):
    exp=0
    for i in range(1,p+1):
        exp+=i/p
    return exp
E=[Ex(pi) for pi in p]

s=sum(E[:K])
retval=s
for i in range(N-K):
    s-=E[i]
    s+=E[i+K]
    retval=max(s,retval)

print(retval)

Submission status: Time Limit Exceeded

Solution code:
import queue
import copy
import math
from collections import deque
import bisect

# 2つの入力を空白で分割し、数値化
n, k = map(int, input().split())

# 空白区切りの数値をリスト化
pn = list(map(int, input().split()))

expects = []

for p in pn:
    e = (((1 + p) * p) // 2) / p
    expects.append(e)

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

print(max_e)

Submission status: Time Limit Exceeded

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

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

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

    print(ans)


main()

Submission status: Time Limit Exceeded

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

exp = [(x+1)*0.5 for x in p]

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

print(max(summed))

Submission status: Time Limit Exceeded

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

n,k=map(int,input().split())
p=np.array(list(map(int,input().split())))
p=(p+1.)/2.
max_p=0

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

print(max_p)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *P = map(int, read().split())

P_ = [0] * N
for i in range(N):
    P_[i] = (1 + P[i]) / 2

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

tuples = [p[i:i+K] for i in range (N-(K-1))]
m = max(map(sum,tuples))

print((m+K)/2)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,K = inputMap()
	P = inputList()

	kikan1 = 0
	kikan2 = 0
	maaxx = 0
	for i in range(N):
		if i+K > N:
			break
		tmp = 0
		for j in range(K):
			tmp += P[i+j]

		if tmp > maaxx:
			maaxx = tmp
			kikan1 = i
			kikan2 = j

	ans = 0
	for j in range(K):
		tmp = P[kikan1+j]
		total = 0
		for jj in range(1,tmp+1):
			total += jj
		ans += total/tmp

	print(ans)

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
nums = list(map(lambda x: int(x), input().split(" ")))
n = nums[0]
k = nums[1]
ps = list(map(lambda x: (int(x) + 1) / 2, input().split(" ")))
res = 0.0
for i in range(n - k + 1):
    res = max(res, sum(ps[i:i+k]))
print(res)

Submission status: Time Limit Exceeded

Solution code:
#400
N,K = map(int,input().split())
p = list(map(int,input().split()))
q = [0 for _ in range(N)]

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

Smax = sum(q[0:K])
for i in range(N-K):
    if sum(q[i+1:K+i+1]) > Smax:
        Smax = sum(q[i+1:K+i+1])

print(Smax)

Submission status: Time Limit Exceeded

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

ls = []
for i in range(n-k+1):
    ans = 0
    for j in range(k):
        for l in range(p[i+j]):
            ans += (1/p[i+j]*(l+1))
    ls.append(ans)
    
print(max(ls))

Submission status: Time Limit Exceeded

Solution code:
N,K= map(int,(input().split()))
p = list(map(int,input().split()))
sum_p=[]
for i in range(N-K+1):
  temp_p=0
  for j in range(K):
    temp_p+=p[i+j]
  sum_p.append(temp_p)
msp=max(sum_p)
ans=(msp/2)+(0.5*K)
print(ans)

Submission status: Time Limit Exceeded

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

    for i in range(N):
        s = 0
        if i+K > N:
            break
        for j in range(K):
            s += (1+pi[i+j])/2
        if s > max_num:
            max_num = s

    print(max_num)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def expected_value(me):
  exp = 0
  for i in range(me):
    exp += ((i+1)/me)
  return exp

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

kaisu = n-k + 1
res = 0
for j in range(kaisu):
  temp = 0
  for jj in range(k):
    temp += expected_value(p[jj + j])
  res = max(res, temp)
print(res)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
ps = list(map(int, input().split()))
ans = 0
max_ps = 0
start = 0

for i in range(n):
    if max_ps <= sum(ps[i:i+k]):
        start = i
        max_ps = sum(ps[i:i+k])

for i in ps[start:start+k]:
    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()))

def f(p):
    #(p*(p+1)/2)/p
    return (p+1)/2


p2 = []

for p_tmp in p:
    p2.append(f(p_tmp))

def func1():
    ans = -1000
    tmp = 0
    for i in range(n):
        if(i<k):
            tmp = tmp + p2[i]
        else:
            tmp = tmp - p2[i-k] + p2[i]
            ans = max(ans,tmp)
    return ans

def func2():
    ans = 0
    for i in range(n):
        tmp = 0
        for j in range(k):
            if(i+j >= len(p2)):
                continue
            tmp = tmp + p2[i+j]
        ans = max(ans,tmp)
    return ans

#print('{:.10f}'.format(func1()))
print('{:.10f}'.format(func2()))

Submission status: Time Limit Exceeded

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

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

print(_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,k=mii()
arr=limii()
temp=0
chk=0
for i in range(n-k+1):
    if chk < sum(arr[i:i+k]):
        temp=i
        chk=sum(arr[i:i+k])
    
aa=arr[temp:temp+k]

ans=0
for i in range(k):
    ans+=(aa[i]*(aa[i]+1)//2)/aa[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
P = list(map(float,input().split()))
anss=0        
for i in range(N-K+1):
    #print(i)
    ans_kari = sum([(P[i+j]+1.0)/2.0 for j in range(0,K)])
    #print(ans_kari)
    #print(i)
    if ans_kari > anss:
        anss = ans_kari

print(anss)

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0
koho = 0

for i in range(n-k+1):
    koho = sum(lst[i:i+k])
    if koho > ans:
        ans = koho

print((ans+k)/2)

Submission status: Time Limit Exceeded

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

#隣接する最大の部分をとって(N+1)/2すればいい

max_part = 0
for i in range(N-K+1):
    x = sum(ps[i:i+K])
    if max_part < x:
        max_part = x

print((max_part+K)/2)

Submission status: Time Limit Exceeded

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

n, k = int(n), int(k)

a = []

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

ans = max(a)

print(ans / 2)

Submission status: Time Limit Exceeded

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

maxP = 0
for i in range(n - k + 1):
  sumK = sum(pList[i:i+k])
  if sumK > maxP:
    maxP = sumK

print((maxP + k) / 2)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    sums = [ sum(p[i:i+K]) for i in range(N-K+1) ]
    print(  ( max(sums)+K)*0.5  )
    return

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = []
    for i in range(K):
        l.append((p[i]*(p[i]+1))//2/p[i])
    ans = sum(l)
    for i in range(K, N):
        l.append((p[i]*(p[i]+1))//2/p[i])
        tmp = sum(l[-K:])
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

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

# p_list = [0] * len(p)
# for i in range(n):
#     p_list[i] = (p[i] + 1) / 2

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

index = 0
max_tmp = 0
for i in range(n-k+1):
    tmp = sum(p[i:i+k])
    if tmp > max_tmp:
        index = i
        max_tmp = tmp

for i in range(index, index+k):
    ans += (p[i] + 1) / 2

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    P = list(map(int, args[1].split()))

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

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Time Limit Exceeded

Solution code:
# 2020/02/09
# AtCoder Beginner Contest 154 - D

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

acm = [0] * n

# Calc
for i in range(k-1, n):
    for j in range(i-k+1, i+1):
        acm[i] = acm[i] + p[j] + 1

ans = max(acm) / 2

# Output
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

  ans = 0.
  for item in _l[start:start+_k]:
    upper = np.sum([j for j in range(item+1)])
    ans += upper / item

  return ans


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

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

Submission status: Time Limit Exceeded

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

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

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

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

print(maxs)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, input().split())
l = list(map(int, input().split()))
max = 0
e = 0
temp = 0
pr = []

for i in range(a-b+1):
  temp = sum(l[i:i+b])
  if temp >= max:
    max = temp
    pr = l[i:i+b]

for j in pr:
  for k in range(1,j+1):
    e += k*(1/j)
  
print(e)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = [int(p) for p in input().split()]
su = 0
for i in range(n-k+1):
    s = sum(P[i:k+i])
    if s > su:
        su = s

    else:
        pass
ans = (su + k)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    res = 0
    maxI = 0
    maxV = 0
    for i in range(N-K+1):
        v = sum(P[i:i+K])
        if v > maxV:
            maxV = v
            maxI = i
    # print(maxI)
    for p in P[maxI:maxI+K]:
        res += (1.0/p) * (p*(p+1.0)/2.0)
    print(res)

main()

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
want = sum(p[0:K])

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

print((K+want)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
l = []
for x in p:
    tmp = 1.0+0.5*(float(x)-1.0)
    l.append(tmp)
max = 0
for i in range(n-k+1):
    tmp = sum(l[i:i+k])
    if tmp >= max:
        max = tmp
print(max)

Submission status: Time Limit Exceeded

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

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


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

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):
  if sum(list(p[i:i+K])) > sum(ans):
    ans = list(p[i:i+K])
    
print((sum(ans)+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
max_l = 0
max_i = 0
ans = 0
if k == 1:
    a = max(l)
    print(a * (a + 1) / 2 / a)
else:
    for i in range(n - k + 1):
        hikaku = sum(l[i:i+k])
        if max_l < hikaku:
            max_i = i
            max_l = hikaku
    for i in range(k):
        a = l[max_i + i]
        ans += a * (a + 1) / 2 / a
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    P = [int(x) for x in stdin.readline().rstrip().split()]
    E = [((p*(p+1))/2)/p  for p in P]
    maxe = 0
    for i in range(N-K+1):
        val = sum(E[i:i+K])
        if maxe < val:
            maxe = val
    print(maxe)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
index = 0
ans = 0
for i in range(N-K+1):
    if sum(p[index:index+K]) < sum(p[i:i+K]):
        index = i
for i in range(index, index+K):
    ans += 0.5*p[i]*(p[i]+1)/p[i]
print(ans)

Submission status: Time Limit Exceeded

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


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


exp = -1
for i in range(len(P)):
    if len(P[i:i + K]) == K:
        e = sum(map(calc_exp, P[i:i + K]))
        if e > exp:
            exp = e

print(exp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

tmp = []
for p in pl:
    tmp.append(p*(p+1)/2/p)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p_list = list(map(int,input().split()))
ans_list = []
def E(me):
    if me == 1:
        return 1
    else:
        return ((1+me)*me/2)/me
E_list = [E(i) for i in p_list]
for i in range(N-K+1):
    ans_list.append(sum(E_list[i:i+K]))
print(max(ans_list))

Submission status: Time Limit Exceeded

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

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

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

print(max)

Submission status: Time Limit Exceeded

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

memo = [0] * n

for i in range(k - 1, len(p)):
    memo[i] = sum(p[i - k + 1:i + 1])

ans = (max(memo) + k) / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import calendar
import fractions
import itertools

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

ans_list = []

for i in p:
    if i % 2 == 0:
        ans_list.append(i / 2 + 0.5)
    else:
        ans_list.append(i // 2 + 1)


ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
n, k = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
p_sum = [sum(p[i:i+k]) for i in range(len(p)-k+1)]
idx = p_sum.index(max(p_sum))
ans = 0
for p_i in p[idx:idx+k]:
    b = 1 / p_i
    for i in range(1, int(p_i+1)):
        ans += i * b
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

N, K = map(int,input().split())
P = list(map(int, input().split()))
Ans = [0]*N
for i in range(N-K+1):
    Ans[i] = sum(P[i:i+K])+K

print(max(Ans)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

for i in range(idx,idx+k):
    p1 = p[i]
    e1 = (1 + p1)*(p1//2 + 0.5*(p1%2))/p1
    e += e1

print(e)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
ki = [0]*1001
for i in range(1, 1001):
    ki[i] = ki[i-1]+i

pp = []
for pa in p:
    pp.append(ki[pa]/pa)

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

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

Submission status: Time Limit Exceeded

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

maxi=-1
sum=0

for i in range(0,N-K+1):
  sum=0
  for j in range(i,i+K):
    sum += (p[j]+1)/2
  maxi=max(maxi,sum)
  
print(maxi)

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):
    ans=max(ans, sum(p[i:i+K]))

print((ans+K)/2)

Submission status: Time Limit Exceeded

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

def expectation(pp):
    return (pp * (pp + 1) / 2) / pp

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

result = 0

ep = [expectation(pp) for pp in p]

save_max = 0

for i in range(N - K + 1):
    save_max = max(sum(ep[i : i + K]), save_max)
    
print(save_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

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

ans = 0
for i in range(ind,ind+K):
    ans += sum(range(1,A[i]+1))/A[i]
    
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
ret = 0
for i in range(n-k+1):
  p_s=0
  for j in range(k):
    p_i = p[i+j]
    p_s+=(1+p_i)*p_i/(2*p_i)
  if p_s>ret:
    ret = p_s
print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#確率は(p_i+1)/2
N, K=(int(i) for i in input().split())
P=[int(i) for i in input().split()]

Q=[(P[i]+1)/2 for i in range(len(P))]
R=[sum(Q[:i]) for i in range(len(Q)+1)]
maxp=0
for i in range(N-K+1):
        maxp=max((R[i+K]-R[i]), maxp)
print(maxp)

Submission status: Time Limit Exceeded

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

array = []
index = 0

for i in range(len(P)-K+1):
    if sum(P[i:i+K]) >= index:
        index = sum(P[i:i+K])
        array = P[i:i+K]


ans = 0
for i in range(K):
    s = 0
    for j in range(1, array[i]+1):
        s += j
    ans += s / array[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_list = list(map(int,input().split()))
max_idx = 0
max_val = 0
for i in range(n-k+1):
    total = sum(p_list[i:i+k])
    if total > max_val:
        max_val = total
        max_idx = i

def exp(n):
    return 1+(n-1)*0.5

print(sum(map(exp, p_list[max_idx:max_idx+k])))

Submission status: Time Limit Exceeded

Solution code:
len_arr, width = map(int, input().split())
dices = list(map(int, input().split()))

ps = [sum(dices[i:i+width]) for i in range(0, len_arr - width + 1)]
idx = ps.index(max(ps))
target = dices[idx:idx+width]

expected = sum([0.5 * (n + 1) for n in target])
print(expected)

Submission status: Time Limit Exceeded

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

expected_vals = [sum(range(p+1)) / p for p in ps]

maxval = 0
for i in range(n - k + 1):
  candidate = sum(expected_vals[i:i+k])
  if candidate > maxval:
    maxval = candidate

print(maxval)

Submission status: Time Limit Exceeded

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

maxi=-1
sum=0

for i in range(0,N-K+1):
  sum=0
  for j in range(i,i+K):
    sum += (p[j]+1)/2
    maxi=max(maxi,sum)
  
print(maxi)

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=(p+1.)/2.
max_p=0

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

print(max_p)