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:
import sys
from pprint import pprint

def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

means = [(1+p)/2. for p in ps]

for i in range(n-k+1):
    cur = sum(means[i:i+k])
    if i == 0:
        out = cur
    else:
        out = max(cur, out)

print(out)

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
data = []
for j in range(N-K+1):
    data.append(sum([p[-i] for i in range(j,K+j)]))

print((max(data)+K)/2)

Submission status: Time Limit Exceeded

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

sumseq = [0] * (nk[0] - nk[1] + 1)
for i in range(nk[0]):
    p[i] = (p[i] + 1) / 2 

for i in range(nk[0] - nk[1] + 1):
    sumseq[i] = sum(p[i:i + nk[1]])


print(max(sumseq))

Submission status: Time Limit Exceeded

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

dq = deque(maxlen=K)
ans = 0
for p in P:
    dq.append(1/p * p * (1 + p) /2)
    ans = max(ans, sum(dq))

print(ans)

Submission status: Time Limit Exceeded

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

# N,K=4 ,1
# s=[6 ,6 ,6 ,6 ]
# list_a=[]
list_b=[]
for i in range(len(s)-K+1):
#     list_a.append(s[i:i+K])
    list_b.append(sum(s[i:i+K]))
print((max(list_b)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
for i in range(n-k+1):
  c = 0
  for j in range(i, i+k):
    c += li_s[j]
    ans.append(c)
print(max(ans))

Submission status: Time Limit Exceeded

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

for i in range(n):
    if p[i] % 2 == 0:
        p[i] = (p[i] + 1) * (p[i] / 2) /p[i]
    else:
        p[i] = ((p[i] + 1) * math.floor(p[i] / 2) + math.ceil(p[i] / 2))  /p[i]

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

print(max)

Submission status: Time Limit Exceeded

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

# １からNまでの値をもつサイコロを振ったときの期待値
def ex(x:int):
    return (x*(x+1)/2)/x

wa=0
saidai_p=0
for i in range(len(p)-(k-1)):
    if sum(p[i:i+k]) >= wa:
        wa=sum(p[i:i+k])
        saidai_p=i

kitaichi_goukei=0
for i in range(k):
    kitaichi_goukei+=ex(p[saidai_p+i])

print (kitaichi_goukei)

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

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int, input().split()))
max=0
index=0
for i in range(len(a)-k+1):
  if max<sum(a[i:i+k]):
    max= sum(a[i:i+k])
    index=i
a=a[index:index+k]
total=0
for i in a:
  total+=sum(range(i+1))/i
print(total)

Submission status: Time Limit Exceeded

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

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

print(((bestP+1)/2).sum())

Submission status: Time Limit Exceeded

Solution code:
a, c = map(int, input().split())
r = a - c + 1

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

j = [0]
for u in range(r):
  g = d[u:u+c]
  if sum(g) > sum(j):
    j = g

q = sum([(k+1) / 2 for k in j])

print(q)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    if sum(p[i:i+k])/k >= b:
        a = max(a,sum([(k+1)/2 for k in p[i:i+k]]))
print(a)

Submission status: Time Limit Exceeded

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

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    memo = []
    for n in range(N):
        group = P[n:n+K]
        memo.append(sum(group))

    print(max(memo))
    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:

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

E = []
for p in P:
    e = 0
    for i in range(1,p+1):
        e += i/p
    E.append(e)

ANS = []

for i in range(N-K+1):
    #print(E[i:i+K])
    ANS.append(sum(E[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()))
d=[]
d2=[]
ans=0
for i in range(n):
  d.append((1+p[i])/2)
for i in range(n-k+1):
  d2.append(sum(d[i:i+k]))
print(max(d2))

Submission status: Time Limit Exceeded

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, K = mulinputs()
# ps = list(mulinputs())
ps = list(map(lambda x: (sum(range(int(x)+1))/int(x)), input().split()))

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


# 出力
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
arr = [int(_) for _ in input().split()]
max = 0
max_p = 0

for i in range(0, n-k+1):
  t = sum(arr[i:i+k])
  if max < t:
    max = t
    max_p = sum([_*(_+1)/(_*2.0) for _ in arr[i:i+k]])

print(max_p)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
p = list(map(int, input().split()))
l=[]
for i in range(N-K+1):
  l=np.append(l,sum(p[i:i+K]))
t=l.argmax()
b=[]
for i in range(K):
  a=sum(range(1,p[t+i]+1))/p[t+i]
  b.append(a)
print(sum(b))

Submission status: Time Limit Exceeded

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


def ex(list):
    ans = 0
    for i in list:
        ans += (i+1)/2
    return(float(ans))


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

print('{:.12f}'.format(ex(maxlist)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

*ev, = map(lambda x: (x*(x+1)/2)/x, p)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
def resolve():
    input = sys.stdin.readline
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    s = []
    m = 0
    for i in range(n-k+1):
        if sum(p[i:i+k]) > m:
            s = p[i:i+k]
            m = sum(s)
    a = 0
    for i in range(k):
        a += (1+s[i])*s[i]/2/s[i]
    print(a)
resolve()

Submission status: Time Limit Exceeded

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

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

ans = [(1+n)/2 for n in max_num]
print(sum(ans))

Submission status: Time Limit Exceeded

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

ans = 0
i = 0 
while i < n:
    list_internal = list[i:k+i]
    e = 0
    j = 0
    while j < len(list_internal):
        e += (list_internal[j]+1)/2
        if ans <= e:
            ans = e
        j += 1
    i += 1
print(ans)

Submission status: Time Limit Exceeded

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

m = 0
import numpy as np
p = np.array(p)
for i in range(n-k+1):
  m = max(m, sum(p[i:i+k]))
print((m + k)/2)

Submission status: Time Limit Exceeded

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

ans = 0
pro = []
for i in range(N):
    dice = p[i:K+i]
    if len(dice) == K:
        if sum(pro) < sum(dice):
            pro = dice

for i in range(len(pro)):
    num = [i for i in range(1, pro[i]+1)]
    ans += sum(num) / pro[i]

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(lambda x: (int(x)+1)/2, input().split()))

ans = 0
for i in range(N-K+1):
    a = sum(P[i:i+K])
    ans = a if a > ans else ans
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
s_max = 0
max_i=0
ret = 0
s_list = [sum(p[i:i+k]) for i in range(n-k+1)]
s_max=max(s_list)
max_i=s_list.index(s_max)

for i in range(k):
  p_i = p[max_i+i]
  ret+=(1+p_i)*p_i/(2*p_i)
  
print(ret)

Submission status: Time Limit Exceeded

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

def estim(n):
    total=0
    for i in range(1,n+1):
        total+=i
    return float(total/n)

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

print(max(final_ans))

Submission status: Time Limit Exceeded

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

sum_num = N - (K - 1)

p_list_Ksum = [sum(p_list[i:i + K]) for i in range(sum_num)]

max_p = max(p_list_Ksum)

print(max_p/2 + 0.5 * K)

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

ans = -1
for i in range(N-K+1):
    sum = 0
    for j in range(K):
        tmp = P[i+j]
        sum += tmp - 0.5*(tmp-1)
    
    ans = max(ans, sum)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[p[i]*(p[i]+1)/2 for i in range(n)]
def Sum(i,k):
  t=0
  for j in range(k):
    t += q[i+j]/p[i+j]
  return t
li=[]
ans=0
for i in range(n-k+1):
  ans = max(ans,Sum(i,k))
print(ans)

Submission status: Time Limit Exceeded

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

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

print((max(s)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().rstrip().split(" "))
p = list(map(int,input().rstrip().split(" ")))
ans = 0
for i in range(N - K + 1):
  karians = 0
  for i2 in range(K):
    karians += p[i + i2] + 1
  if ans <= karians:
    ans = karians
print(ans / 2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
listp = list(map(int, input().split()))
listans1 = []
for n in range(N-K+1):
    b = sum(listp[n:n+K])
    listans1.append(b)
#print(listans1) 
print((max(listans1)+K)/2)

Submission status: Time Limit Exceeded

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


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

print((Msum+k)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

convolved = np.convolve(expected_vals, np.ones(k))

print(max(convolved))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=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
	else:
		cnt=cnt
	#print(cnt)
for i in range(tmp,tmp+K):
	ans+=(P[i]*(P[i]+1)/2/P[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p_ = []
for i in p:
  p_.append(sum(range(i+1))/i)
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())
p = [int(x) for x in input().split()]

l = 0
r = k

result = 0.0
m = 0
while r != len(p)+1:
  pp = p[l:r]
  l += 1
  r += 1
  s = sum(pp)
  if s <= m:
    continue
  m = s
  this_res = 0.0
  # 期待値の計算
  for pi in pp:
    this_res += pi / 2 + 1/2
  result = max(result, this_res)

print(result)

Submission status: Time Limit Exceeded

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

k = [0]*N

def kitaiti(n):
    sum = 0
    for i in range(1,n+1):
        sum += i
    return sum / n
    
for i in range(N):
    k[i] = kitaiti(p[i])
ans = 0
for i in range(N-K+1):
    ans = max(ans,sum(k[i:i+K]))
print(ans)

Submission status: Time Limit Exceeded

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

p = [ (p+1)/2 for p in ps]

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

print(pn_max)

Submission status: Time Limit Exceeded

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

m = 0
for i in range(len(l)-(K-1)):
    if m < sum(l[i:i+K]):
        m = sum(l[i:i+K])
        t = l[i:i+K]
        
def E(n):
    return sum(range(1,n+1)) / n

l2 = list(map(E, t))

print(sum(l2))

Submission status: Time Limit Exceeded

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

for i in range(0, N-K+1):
    sum_P = sum(P[i:i+K])
    ans = max(ans, sum_P)
#     ans = max(ans, K+0.5*(sum_P-K))
    
print(K+0.5*(ans-K))

Submission status: Time Limit Exceeded

Solution code:
def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	maxl = [sum(a[0:m])]
	i = 1
	while i + m <= len(a):
		maxl.append(max(sum(a[i:i+m]),maxl[-1]))
		i += 1
	ans = 0
	for i in range(m):
		for t in range(1,a[maxl.index(max(maxl))+i]+1):
			ans += t * (1/(a[maxl.index(max(maxl))+i]))
	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()))

expect_value = [0]*N

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

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

Submission status: Time Limit Exceeded

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

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

maxx = 0
for i in range(n-k+1):
  m = 0
  for j in range(k):
    m += p[i+j]
  if m > maxx:
    maxx = m
    idx = i
s = 0
for i in range(k):
  s += su(p[idx+i])/p[idx+i]
print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans1)

Submission status: Time Limit Exceeded

Solution code:
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))
ans=sum(P[0:K])
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:
nk = list(map(int,input().split()))
p = list(map(int,input().split()))

sumseq = [0] * (nk[0] - nk[1] + 1)
for i in range(nk[0]):
    p[i] = (p[i] + 1) / 2 

for i in range(len(sumseq)):
    sumseq[i] = sum(p[i:i + nk[1]])


print(max(sumseq))

Submission status: Time Limit Exceeded

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

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

maxval = 0

def expectedval(inp):
	return (1 + inp) * (inp/2) / inp


for i in range(n-(k-1)):
	summ = 0
	for j in range (k):
		summ += expectedval(plist[i + j])
	maxval = max(summ, maxval)

print(maxval)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
d = defaultdict(int)

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

for i in range(1, 1000+1):
  t = 0
  for s in range(1, i+1):
    t += s * (1 / i)

  d[i] = t

ans = 0

for index, i in enumerate(li):
  if index + K > N:
    break

  t = 0
  for k in range(K):
    t += d[li[index+k]]

  if ans < t:
    ans = t

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def expect(num):
    sum
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    su = 0
    l_sum = []
    i = 0
    while (N-K) >= i:
        tmp_p = p[i:(i+K)]
        if sum(tmp_p) >= su:
            su = sum(tmp_p)
            l_sum = tmp_p
        i += 1

    ans = 0
    for l in l_sum:
        r = l * (l+1)
        r = r/2
        ans += r/l
    print(ans)



    return 0

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

  ans = 0.
  for item in _list[start:start+_k]:
    upper = 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:
n,k = map(int,input().split())
li = list(map(int,input().split()))
ans = 0
li_2 = []
for i in range(n-k+1):
  num = sum(li[i:i+k])
  li_2.append(num)
print(max(li_2)*0.5 + 0.5*k)

Submission status: Time Limit Exceeded

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

def Ex(n):
  return sum(range(1,n+1))/n
 
out = [0]*K
_max = 0
for i in range(N):
  curr = Ex(ps[i])
  tmp = sum(out[1:]) + curr
  _max = max(_max, tmp)
  out = out[1:] + [curr]
print(_max)

Submission status: Time Limit Exceeded

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

max_s = 0
len_P = len(P)
for i in range(len_P):
  if i+K < len_P and P[i] < P[i+K]:
    continue
  sum_K = sum(P[0+i:K+i])
  if max_s < sum_K:
    max_s = sum_K
print((max_s+K) / 2)

Submission status: Time Limit Exceeded

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


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

P = [(1 + k)*(k/2)/k for k in P]

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

print(s)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N_K = LIST()
P = LIST()

N = N_K[0]
K = N_K[1]

max = 0
max_list = []
for i in range(0, N-K+1):
    tmp = np.sum(np.array(P[i:i+K]))
    # tmp = sum(P[i:i+K])
    if tmp > max:
        max_list = P[i:i+K]
        max = tmp

ans = 0
for i in max_list:
    ans += (1 + i) / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:

def E(x):
    ans = 0
    for i in range(x):
        ans += (i+1)
    ans /= x
    return ans

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

p = list(map(int,input().split()))
E_lis = [E(i) for i in p]
res = []

for i in range(len(p)-k+1):
    temp = 0
    for j in range(k):
        temp += E_lis[i+j]
    res.append(temp)
print(max(res))

Submission status: Time Limit Exceeded

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

now = 0

for i in range(n-k+1):
  now = max(sum(l[i:i+k]), now)
  
print((now + k) / 2)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
final = []
#最大のリストを選定
for i in range(0,n-k+1):
    ck = sum(p[i:i+k])
    if ck > max:
        max = ck

#計算
print((max+k)/2.0)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

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

max_value = -1
max_index = -1

for i in range(N - K + 1):
  s = sum(P[i:i+K])
  max_value = max(max_value, s)
  if max_value == s:
    max_index = i

print(sum([calc(P[i]) for i in range(max_index, max_index + K)]))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K = map(int, input().split())
P = list(map(int, input().split()))
def f(n):
  return (n+1)/2
PP = list(map(f, P))

a = np.array(PP)
v = np.array(K*[1])
print(max(list(np.convolve(a,v, mode='same'))))

Submission status: Time Limit Exceeded

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

for i in range(len(p)):
    p[i] = 0.5*(p[i]+1)
for i in range(len(p)-k+1):
    sum_ = sum(p[i:i+k])
    ans = max(ans, sum_)
print(ans)

Submission status: Time Limit Exceeded

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

max_index = 0
max_sum = -10000
for i in range(0, N):
  if i+K > N:
    break
  tmp = sum(p_list[i:i+K])
  if tmp > max_sum:
    max_sum = tmp
    max_index = i

avg = 0
for i in range(max_index, max_index+K):
  avg += (p_list[i]+1) / 2

print(avg)

Submission status: Time Limit Exceeded

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

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

    if(ans < tmp):
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    S = 0
    for j in range(K):
        S += (sum([n for n in range(1,p[i+j]+1)])/p[i+j])
    if M < S:
        M = S

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
ar = map(int, input().split())
ar = np.array(list(ar))
expect = (ar + 1)/2
sw = np.convolve(expect, np.ones(K, dtype=int), 'valid')
m = np.max(sw)
print(m)

Submission status: Time Limit Exceeded

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

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

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

print(max(_p))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
p = list(map(int, input().split()))
pn = np.array(p)
v = np.array([1]*k)
c = np.convolve(pn, v, mode='same')
print((max(c)+k)/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
max_index = 0
max_size = 0
for i in range(N-K+1):
    sum_3 = sum(P[i:i+K])
    if sum_3 > max_size:
        max_index = i
        max_size = sum_3
expect = 0
for j in range(K):
    expect += (P[max_index+j]+1)/2
print(expect)

Submission status: Time Limit Exceeded

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

sum_temp_list = []
for i in range(len(p_list)-k+1):
    sum_temp = sum(p_list[i:i+k])
    sum_temp_list.append(sum_temp)
    
index = sum_temp_list.index(max(sum_temp_list))

kitaichi = 0
for i in range(k):
    temp_index = index + i
    kitaichi += (1+p_list[temp_index])/2
    
print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
e1 = list(map(lambda x: (x+1)/2, P))

ans = 0
for i in range(N-K+1):
    a = sum(e1[i:i+K])
    ans = a if a > ans else ans
print(ans)

Submission status: Time Limit Exceeded

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

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

sumM = 0
idx = 0
for i in range(n-k+1):
  tmp = 0
  for j in range(i,i+k):
    tmp += dList[j]
  if sumM < tmp:
    sumM = tmp
    idx = i
result = 0
for i in range(idx,idx+k):
  result += dList[i]*0.5+0.5

print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

p2 = [0 for i in range(len(p))]
for i,px in enumerate(p):
  p2[i] = (px+1)/2

max_ans = 0
for i in range(0, N-K+1):
  ans = sum(p2[i:i+K])
  if ans > max_ans:
    max_ans = ans
    
print(max_ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
m=0
S=0
t=0
x=0

for i in range(N-K+1):
  for k in range(K):
    S+=(1+p[i+k])/2
    if (i+k)==(i+K-1):
      if m<S:
        m=S
      S=0



print(m)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

kitaichi_p_list = [(p + 1)/2 for p in p_list]

max_kitaichi = 0
for i in range(N):
    kitaichi = sum(kitaichi_p_list[i:i+K])
    if(max_kitaichi < kitaichi):
        max_kitaichi = kitaichi

print(max_kitaichi)

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
 
print(sum(map(lambda x: sum(list(range(1, x+1)))/x, P[m_index : m_index+K])))

Submission status: Time Limit Exceeded

Solution code:
import sys
from io import StringIO
import unittest

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

    loop=n-k+1

    ms=0

    for i in range(loop):
        tmp=0
        for j in range(k):
            tmp+=p[i+j]/2+1/2
        if tmp > ms:
            ms = tmp

    print(ms)

    return

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

Submission status: Time Limit Exceeded

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

E = [p*(p+1)/2/p for p in P]

ans = 0.0
for i in range(K,N+1):
  if sum(E[i-K:i])> ans:
    ans = sum(E[i-K:i])
print(float(ans))