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 numpy as np
n,k = list(map(int,input().split()))
p = np.array(list(map(int,input().split())))

P = 0
for i in range(n-k+1):
  sp = p[i:i+k].sum()
  if P < sp:
    P = sp
    mp = p[i:i+k]

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

print(ans)

Submission status: Time Limit Exceeded

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

maxList = []
kitaichi = 0
for index in range(len(p)):
  if sum(p[index:index+K]) > sum(maxList):
    maxList = p[index:index+K]

for item in range(len(maxList)):
  s = sum(list(range(maxList[item]+1)))
  kitaichi += s / maxList[item]

print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:

N,K = map(int,input().split())
P_List=list(map(int,input().split()))
#print(N,K)
#print(P_List)

def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    #print(p,result)
    return result

pre_max=0
temp_max=0
max_num=0
for j in range(N-(K-1)):
    for k in range(K):
        #temp_max += P_List[j+k]
        temp_max += Kitaichi(P_List[j+k])
    #print(temp_max)

    if pre_max < temp_max:
        pre_max = temp_max
        max_num = j
    temp_max=0

#print('max_num:',max_num)
#result = 0
#for l in range(K):
#    result += Kitaichi(P_List[max_num+l])

#print(result)
print(pre_max)

Submission status: Time Limit Exceeded

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

P = []
for i in range(N):
    if p[i] == 1:
        P.append(1)
    else:
        P.append((p[i]+1)/2)

Max = 0
Max1 = 0
for i in range(N-K+1):
    Max1 = 0
    for k in range(i,i+K):
        Max1 += P[k]
    if Max1 > Max:
        Max = Max1

print(Max)

Submission status: Time Limit Exceeded

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

  pp = np.array([0.5*(i+1) for i in p])
  ind =0
  m=0
  
  for i in range(N-K+1):
    ne = sum(p[i:i+K])
    if m < ne:
      ind = i
      m = ne

  print(sum(pp[ind:ind+K]))
main()

Submission status: Time Limit Exceeded

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

d = {}
def kitaichi(n):
	if n in d.keys(): return d[n]
	else:
		sum = n * (n+1) / 2
		d[n] = sum / n
		return d[n]

ans = 0
for i in range(len(p)):
	pp = p[i:i+k]
	if len(pp) != k: break
	tmp = 0
	for j in pp:
		tmp += kitaichi(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()))
sum_a = 0
index = 0
for i in range(n):
    num = 0
    
    if (int(i)+k<=n):
        for j in range(int(i),int(i)+k):
            num += P[j]
        if(sum_a<num):
            index = i
            sum_a = num
            #print(sum_a,index)
total = 0.0
for m in range(index,index+k):
    total += sum(list(range(P[m]+1)))/P[m]
print(total)

Submission status: Time Limit Exceeded

Solution code:
def culc_expected_value(num):
  output = 0
  if num != 1:
    for i in range(1, num+1):
      output = output + i/num
  else:
    output = 1
  return output
 
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_nums = 0
max_targets = []
for j in range(0, len(p_list)-k+1):
  targets = [p_list[j+m] for m in range(k)]
  t_sum = sum(targets)
  if t_sum >= max_nums:
    max_nums = t_sum
    max_targets = targets
# print(max_targets)

ans = 0
for t in max_targets:
  ans += culc_expected_value(t)
  # print(ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#期待値関数
def ex_value(dice):
    n = 0
    for i in range(1,dice+1):
        n += i*1/dice
    return(n)

n,k = map(int, input().split())
list_p = list(map(int, input().split()))
list_ex_val = list(map(ex_value, list_p))
sum_k=[]
for i in range(n-k+1):
    sum_k.append(sum(list_ex_val[i:i+k]))
print(max(sum_k))

Submission status: Time Limit Exceeded

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

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

for i in range(n-k+2):
  li0[i-1] = sum(li[i-1:i+k-1])
  if 1 == i:
    limax = li0[0]
  if 1 < i:
    limax = max(limax,li0[i-1])
print((limax+k)/2)

Submission status: Time Limit Exceeded

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


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

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def calc_ex(x):
  p = 1 / x
  ex = 0

  # ex_list = list(range(x))
  # ex_list = list(map(lambda s: (s + 1) * p, ex_list))


  for i in range(x + 1):
    px = p * i
    ex += px

  return ex

ans = 0

n, k = map(int, input().split())
p = [int(i) for i in input().split()]
# p_ex = list(map(calc_ex, p))

ans_list = [0]

for i in range(n - k + 1):
  new_list = p[i:(i + k)]
  if sum(new_list) > sum(ans_list):
    ans_list = new_list



print(sum(list(map(calc_ex, ans_list))))

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np


def solve():
    N, K, *P = map(int, sys.stdin.read().split())
    P = np.array(P)
    n = np.convolve(P, np.ones(K), mode='valid').argmax()
    cusum = np.array(range(1000+1)).cumsum()
    return np.sum(cusum[P[n:n+K]] / P[n:n+K])


if __name__ == "__main__":
    answer = solve()
    print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

expects = []
for x in P:
    ex = 0
    for i in range(1, x + 1):
        p = i / x
        ex += p
    expects.append(ex)

ans = 0
ll = len(expects)
for i in range(0, ll):
    ex = sum(expects[i:i + K])
    if ans < ex:
        ans = ex

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
x=np.array(w)
for i in range(q[0]-q[1]+1):
  k=0
  k=np.sum(x[i:i+q[1]])
  if a<k:
    a=k
    memo=i
print((a+q[1])/2)

Submission status: Time Limit Exceeded

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

import numpy as np

numlist = []

for i in range(K):
    list = P[i:] + P[:i]
    numlist.append(list)

numlist = np.array(numlist)

wa = np.sum(numlist, axis=0)

max_index = np.argmax(wa[:N-K+1])
#print(max_index)

max = P[max_index:max_index+K]
#print(max)

ans = 0
for i in max:
    ans += (i*(1+i)/2)/i

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
p = list(map(int, input().split()))
big = []
Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        for j in range(K):
            Sum += p[i + j]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
for i in range(K):
    big.append(p[index+i])
ans = []
for i in big:
    kitai=0
    for j in range(1,i+1):
        kitai += j
    kitai = kitai / i
    ans.append(kitai)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    input = sys.stdin.readline

    N,K = map(int,input().split())
    p_list = tuple(map(int,input().split()))

    max_sum = 0
    for i in range(N):
        tmp_sum = sum(p_list[i:i+K])
        if(max_sum < tmp_sum):
            max_sum = tmp_sum
            ichi = i

    kitaichi = ((p+1)/2 for p in p_list[ichi:ichi+K])

    print(sum(kitaichi))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

s = 0
max_s = 0
max_i = 0

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

    if s > max_s:
        max_s = s

print((max_s + k) / 2)

Submission status: Time Limit Exceeded

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

sum_p = []

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

ex = sum(list(range(1,max(sum_p)-K+2))) / (max(sum_p)-K+1)

print(ex + K - 1)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(N-K+1):
    xxx = 0
    for j in range(i, i+K):
        xxx += (1+p[j])/2
        
    if ans < xxx:
        ans = xxx

print(ans)

Submission status: Time Limit Exceeded

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

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

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

ans = 0
a =0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

d = {}
def kitaichi(n):
	if n in d.keys(): return d[n]
	else:
		sum = 0
		for i in range(n+1):
			sum += i
		sum = n * (n+1) / 2
		d[n] = sum / n
		return d[n]

ans = 0
for i in range(len(p)):
	pp = p[i:i+k]
	if len(pp) != k: break
	tmp = 0
	for j in pp:
		tmp += kitaichi(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()))
memo = P[:K]
ans = sum(memo)

for i in range(K, N):
    memo.pop(0)
    memo.append(P[i])
    ans = max(ans, sum(memo))

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

maxx = 0
for i in range(n-k+1):
  m = 0
  m = sum(p[i:i+k])
  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:
import numpy as np
n, k = map(int, input().split())
P = list(map(int, input().split()))
 
ans4 = list()
for i in range(n - (k-1)):
    ans4.append(sum(P[i:i+k]))
 
am = np.argmax(ans4)
am2 = P[am:am+k]
ans = 0
for i in am2:
    for j in range(1, i + 1):
        ans += j / i
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(len(p)-k+1):

    an = 0

    for j in range(k):

        for l in range(1, p[i+j] + 1):
            an += l/p[i+j]

        ans.append(an)

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
from itertools import count, islice

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

Submission status: Time Limit Exceeded

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

def kitai(x):
  p = 1/x
  ex = 0
  for i in range(1, x+1):
    px = p*i
    ex += px
  return ex

mem = {}
isum = 0
keys = (0, 0)
for i in range(n):
  if i+k > n:
    break
  temp = p[i:i+k]
  if sum(temp) > isum:
    isum = sum(temp)
    keys = (i, i+k)

ans = 0
for i in p[keys[0]:keys[1]]:
  if i in mem:
    ans += mem[i]
  else:
    m = kitai(i)
    ans += m
    mem[i] = m
print(ans)

Submission status: Time Limit Exceeded

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

def get_max_val(v_list, n, k):
  max_val=0
  for i in range(n+1-k):
    last_index = i + k
    use_list = v_list[i:last_index]
    val = (sum(use_list) + k) / 2
    if val > max_val:
      max_val = val
  return max_val
  
print(get_max_val(v_list, n, k))

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())))+1)/2
ans = 0.0
for i in range(n-k+1):
    temp=np.sum(P[i:i+k])
    if ans<=temp:
        ans=temp
print(ans)

Submission status: Time Limit Exceeded

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


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


s1 = [(1 + P[k])*(P[k]/2)/P[k] for k in range(index,index+K)]


print(sum(s1))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(set,set+k):
  ans += sum(range(1,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()))
A=[0]
if K!=1:
  for k in range(0,N-K+1):
    On=0
    for l in range(0,K):
      On+=P[k+l]
    A.append(On)
  print((max(A)+K)/2)
else:
  print((max(P)+1)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
P = list(map(int,input().split()))
sum_a = 0
index = 0
for i in range(n):
    num = 0
    
    if (int(i)+k<=n):
        for j in range(int(i),int(i)+k):
            num += P[j]
        if(sum_a<num):
            index = i
            sum_a = num
            #print(sum_a,index)
total = 0.0
for m in range(index,index+k):
    mylist = list(range(P[m]+1))
    #print(sum(mylist))
    total += sum(list(range(P[m]+1)))/P[m]
print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

x = input().split()
n = int(x[0])
k = int(x[1])

p = input().split()

e_max = 0
for i in range(n-k+1):
  e = 0
  for j in range(k):
    q = int(p[i+j])
    e += ((q*(2+q-1))/2)/q                 
  if e_max < e:
    e_max = e

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

Submission status: Time Limit Exceeded

Solution code:

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

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

    if s_max < s:
        s_max = s

print((s_max+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
q = [0]*(N-K+1)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N, K = [int(i)for i in input().rstrip().split(' ')]
_p = [int(i)for i in input().rstrip().split(' ')]
v = N-K+1
maxs = 0
idx = 0;

for i in range(v):
    l = [_p[j] for j in range(i, i+K)]
    if sum(l) > maxs:
        idx = i;
        maxs = sum(l)

s = 0;
for i in range(idx, idx+K):
    s += calc(_p[i])
print(s)

Submission status: Time Limit Exceeded

Solution code:
n, k, *p_n = map(int, open(0).read().split())

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

for i in range(n - k + 1):
    total = 0
    for j in range(k):
        total += (p_n[i + j] + 1)
        
    exp[i] = total * 0.5
    
print(max(exp))

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(p[i:i+k])
lstpp = []
for j in lstp:
    lstpp.append(0.5*(sum(j)+k))
print("{:.10f}".format(max(lstpp)))

Submission status: Time Limit Exceeded

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

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

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import collections

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

Submission status: Time Limit Exceeded

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

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
max_ans = ans
max_index = 0

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    if max_ans < ans:
        max_ans = ans
        max_index = i+1

ans = 0
al = []
for i in range(k):
    pp = p[max_index+i]
    if pp == 200000:
        ans += 2000010000.0000002
    else:
        for j in range(pp):
            ans += (1/pp*(j+1))
            al.append(ans)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line
N, K = tuple(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
a = dict()
for i in range(N - K + 1):
    # sum = 0
    # for j in range(K):
    #     sum += (1 + p[i+j]) / 2
    # a.append(sum)
    a[sum(p[i:i+K])] = i

ans_key = max(a.keys())
sum = 0
for j in range(K):
    sum += (1 + p[a[ans_key]+j]) / 2
print(sum)

Submission status: Time Limit Exceeded

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


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

    max = 0
    idx = 0
    E = []
    for n in range(N):
        if n <= N-K:
            sums = sum(P[n:n + K])
            if max < sums:
                max = sums
                idx = n
        e = 0.5 * (1 + P[n])
        E.append(e)
    print(sum(E[idx:idx+K]))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(float,input().split()))
exp=tuple([(pi+1)/2 for pi in p])
ans=0
for i in range(0,n-k+1):
  ans=max(ans,sum(exp[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()]
ans = [sum(p[i : i + K]) for i in range(N-K+1)]

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=list(map(int, input().split()))
cnt=0
for i in range(N):
    if K+i<=N:
            B=A[i:K+i]
            res=[]
            for b in B:
                tmp=0
                for i in range(1,b+1):
                    tmp+=i
                res.append(tmp/b)
    if cnt<sum(res):
        cnt=sum(res)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
for j in range(N-K+1):
    if j==0:
        kouho.append(sum(hako))
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        hako.pop(0)
        kouho.append(sum(hako))
#print(kouho)
print(max(kouho))

Submission status: Time Limit Exceeded

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


maximum = 0
for i in range(b):
  n = l[i:i+a[1]].sum()
  if n > maximum:
    maximum = n

print(0.5*(maximum+a[1]))

Submission status: Time Limit Exceeded

Solution code:
def expect_value(number):
  expect = 0
  for i in range(1, number+1):
    expect = expect + i / number
  return expect
  
N, K = map(int, input().split())
num = list(map(int, input().split()))

expect = []

# 各サイコロの期待値を出す
for i in range(N):
  expect.append(expect_value(num[i]))

# 隣接するN個の期待値を出す
max = 0
for i in range(N):
  if i > N - K:
    break
  temp = 0
  for j in range(K):
	  temp = temp + expect[i + j]
  if max < temp:
    max = temp
print(max)

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

for i in range(0, N):
  if i+K > N:
    break

  if i == 0:
    max_sum = sum(p_list[0:K])+K
  else:
    if p_list[i-1] < p_list[i-1+K]:
      tmp = sum(p_list[i:i+K])+K
      if max_sum < tmp:
        max_sum = tmp

print(max_sum/2)

Submission status: Time Limit Exceeded

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


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

l = []
for i in p:
    l.append(kita(i))

if n == k:
    print(sum(l))

else:
    a = []
    for i in range(n):
        len_s = len(l[i:i + k])
        if len_s < k:
            break
        else:
            a.append(sum(l[i:i + k]))

    print(max(a))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# /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())
# memo = dict()
# def kitaiti(s):
#     if s in memo.keys():
#         return memo[s]
#     n = int(s)
#     k = ((n*(1+n))>>1)/int(n)
#     memo[s] = k
#     return k
# ps = list(map(kitaiti, input().split()))

ans, cp = 0, []
for i in range(N-K+1):
    t = sum(ps[i:i+K])
    if ans >= t:
        continue
    cp = ps[i:i+K]
    ans = t
    # ans = max(ans, sum(ps[i:i+K]))


cnt = 0
for i in range(K):
    n = cp[i]
    cnt += ((n*(1+n))>>1)/n

# 出力
print(cnt)

Submission status: Time Limit Exceeded

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


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
sum_dice_num = 0
ans = 0.0

for i in range(n-k_range+1):
    k_dice_num = sum(p[i:i+k_range])
    if k_dice_num < sum_dice_num:
        continue
    else:
        e = sum([calc_expected_value(p[i+k]) for k in range(k_range)])
        sum_dice_num = k_dice_num
        ans = max(ans, e)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
tes = 0.0
SS = {sum(B[i:i+A[1]]):B[i:i+A[1]] for i in range(len(B)-A[1]+1)}
tes += sum([sum(i) for i in [[float(1/len(list(range(1,max(SS.values())[i]+1)))*x) for x in list(range(1,max(SS.values())[i]+1))] for i in range(len(max(SS.values())))]]) 
print(float(tes))

Submission status: Time Limit Exceeded

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

exp = 0
for idx in range(n - (k - 1)):
    tmp = (sum(pi[idx : idx + k]) + k) / 2
    if exp < tmp:
        exp = tmp

print(exp)

Submission status: Time Limit Exceeded

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

pos = 0
saidai = 0
for i in range(N-K+1):
  temp = sum(list(map(lambda x: (x+1)/2, p[i:i+K])))
  if saidai < temp:
    saidai = temp
print('{:.12f}'.format(saidai))

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import *
from heapq import *
from fractions import gcd
import itertools
import math
import numpy as np

sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()

N, K = InMap()
P = np.array(InMap())
P += 1
v = np.ones(K)
Res = np.convolve(P, v)
# Res = [sum(E[i:i+K]) for i in range(N-K+1)]
print(max(Res) / 2)

Submission status: Time Limit Exceeded

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

def calc(n):
    return sum([i for i in range(1, n+1)]) / n

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

print(max_ex)

Submission status: Time Limit Exceeded

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


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

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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


tmp = 0
tmp_i = 0
for i in range(n-k+1):
    a = sum(tuple(p[x] for x in range(i, i+k)))
    if a > tmp:
        tmp = a
        tmp_i = i

ans = tuple(kitaichi(p[tmp_i+x]) for x in range(k))
print(sum(ans))

Submission status: Time Limit Exceeded

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

num_li = [0]*n
ans = 0
num = 0

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

ans = sum(num_li[:k])

for j in range(n-k+1):
    num += num_li[j]
    for m in range(1,k):
        num += num_li[j+m]
    ans = max(num, ans)
    num = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
class Dice():
    def __init__(self, N, K):
        self.ex = 0.0
        self.N = N
        self.K = K
        self.max = 0

    def calc_ex(self, P):
        i = 0
        end = self.K
        while i + end <= self.N:
            check_num = P[i:i + end]
            total_num = sum(check_num)
            if total_num > self.max:
                self.max = total_num
                self.ex = 0
                self.ex = (self.max + end)/2
                # for j in check_num:
                #self.ex += (j + 1) / 2
            i += 1
        return


N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
dice = Dice(N, K)
dice.calc_ex(P)
print("%.12f" % dice.ex)

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):
	gokei = 0
	gokei = sum(p[i:(i+K)])
	if saidai < gokei:
			saidai = gokei

print((saidai+K)/2)

Submission status: Time Limit Exceeded

Solution code:
import time
N, K = map(int, input().split())
A = list(map(int, input().split()))

def CalExVal(x):
    return (1/2*(x+1))
Ex = list(map(CalExVal, A))
temp = len(A)-K + 1
#adjlist = [0]*(temp)
adjlist = [sum(Ex[i:(K+i)]) for i in range(temp)]
#for i in range(temp):
#    adjlist[i] = sum(Ex[i:(K+i)])

print(max(adjlist))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = map(int, input().split())
    dice_num = list(map(int, input().split()))
    result = 0
    val = 0
    start_num = 0

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

    for i in range(start_num, start_num + k):
        dice = dice_num[i]
        for i in range(1, dice + 1):
            result += i * 1 / dice

    print(result)


if __name__ == "__main__":
    main()