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()))
kitai = []
for i in range(1,n+1):
    sum_k = 0
    for j in range(1,p[i-1]+1):
        sum_k += j *(1/p[i-1])
    kitai.append(sum_k)
ans = []
sum_ans = 0
for i in range(k):
    sum_ans += kitai[i]
ans.append(sum_ans)
j = 0
cnt = 0
for i in range(k,len(kitai)):
    sum_ans = ans[cnt]
    sum_ans -=kitai[j] 
    sum_ans += kitai[i]
    j +=1
    cnt+=1
    ans.append(sum_ans)
print(max(ans))

Submission status: Time Limit Exceeded

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

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

mx=0
for i in range(n-k+1):
    tmp=sum(p[i:i+k])
    if mx<tmp:
        ind=i
        mx=tmp
        
ans=0
for i in range(k):
    ans+=1+(p[ind+i]-1)*0.5
    
print(ans)

Submission status: Time Limit Exceeded

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

max_total = 0
index_first = 0
index_end = 0
for i in range(N - K + 1):
    if max_total < sum(p[i:i+K]):
        max_total = sum(p[i:i+K])
        index_first = i
        index_end = i+K

ans = 0
for i in range(index_first,index_end):
    ans += ((p[i] * (p[i] + 1)) /2) * (1/p[i])
print(ans)

Submission status: Time Limit Exceeded

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

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

print((p3max+k)/2.0)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

exp={}

ans=0
cnt=0
for i in range(1,1001):
    sum=0
    for j in range(1,i+1):
        sum+=j
    exp[i]=sum/i

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
    e += np.sum(np.arange(int(p[i+j])+1))/int(p[i+j])
  if e_max < e:
    e_max = e

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

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 kitaichi(num):
    return (sum(range(num+1)) / num)


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

ans = 0
for x in range(k):
    ans += kitaichi(p[tmp_i+x])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K = map(int,input().split())
L = [int(x) for x in input().split()]
S = [0]
for x in range(N-K+1):
    NL = L[0+x:K+x]
    if sum(NL) > sum(S):
        S = NL
ANS = 0
for x in S:
    LL =np.array(range(1,x+1))
    ANS += sum([1/len(LL)*x for x in LL])
print(ANS)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

c = np.array([sum(b[i:i+a[1]]) for i in range(0, len(b) - a[1] + 1)])
d = c.argmax()
m = c[d]

t = [sum(range(1, d + 1)) / d for d in range(1, m + 1)]

e = b[d:d+a[1]]
f = sum([t[d-1] for d in e])

print(f)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
num_list = list(map(int, input().split()))
out = 0.0
for j in range(a - b + 1):
    k_list = num_list[j:j+b]
    k_sum = 0.0
    for i in k_list:
        k_sum = k_sum + ((1 + i) * i / 2) / i
        out = max(out, k_sum)
print(out)

Submission status: Time Limit Exceeded

Solution code:
s = input().split()
t = input().split()
num = int(s[0])
kumi = int(s[1])
res = 0
for i in range(num -kumi +1):
  tmp =0
  for j in range(kumi):
    cnt =0
    for k in range(int(t[i+j])):
      cnt += k+1
    tmp += cnt/int(t[i+j])
  if tmp > res:
    res = tmp
print(res)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int,input().split())
p = [(int(a) * (int(a)+1) / 2 / int(a)) for a in input().split()]
s = np.array(p)
max_index = 0
max_sum = 0
for i in range(n-k+1):
  t = np.sum(s[i:i+k])
  if max_sum < t:
    max_sum = t
    max_index = i

print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
max = 0
index = 0
res = 0

for i in range(n-k+1):
    pre = List[i]
    for j in range(k-1):
        pre += List[i+j]
    #print(max)

    if max < pre:
        max = pre
        index = i
        pre = 0
    else:
        pre = 0
    
#print(index)
for i in range(index, index+k):
    res += 1 + 0.5 * (List[i]-1)
    #print(List[i])

print(res)

Submission status: Time Limit Exceeded

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

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 = InMap()
E = [(p+1)/2 for p in P]
Res = [sum(E[i:i+K]) for i in range(N-K+1)]
print(max(Res))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    mod = 10**9+7

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

    for i in range(n - k + 1):

        count = sum(kitai[i:i+k]) % mod
 #       for w in range(i , i + k):
#            count += kitai[w]
#            count += tasu(p[w]) / p[w]
        ans = max(ans , count)

    return ans

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def create_arr(v_list, n, k):
  base_arr = v_list[0:n+1-k].copy()
  for i in range(1, k):
    base_arr += v_list[i:n+1+i-k]
  return base_arr
base_arr = create_arr(v_list, n, k)
print((base_arr.max()+k)/2)

Submission status: Time Limit Exceeded

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

memo = [-1]*K

for memo_i in range(K):
    memo[memo_i] = P[memo_i]

ans = sum(memo)

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

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

Submission status: Time Limit Exceeded

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

if k == 1:
  print(max(li))
else:
  li2 = [sum(li[m:m+k]) for m in range(0, len(li) - k + 1, 1)]
  print(max(li2))

Submission status: Time Limit Exceeded

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

max_val = 0
max_idx = 0
tmp = 0
for i in range(1,N-K+2):
  if i == 1:
    tmp = sum(p[i-1:i-1+K])
  else:
    tmp = tmp - p[i-2] + p[i-2+K]
  if tmp > max_val:
    max_val = tmp
    max_idx = i

expect = 0.0
for i in range(max_idx, max_idx+K):
  tmp = 0.0
  for j in range(1,p[i-1]+1):
    tmp += j
  expect += tmp/p[i-1]
print(expect)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
n,k = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
p = list(map(int, stdin.readline().rstrip().split()))

ans = 0
for i in range(n-k+1):
    sum = 0
    for j in range(k):
        sum += p[i+j]
    ans = max(sum,ans)
    if ans == sum:
        real = 0
        for l in range(k):
            s = 0
            num = p[i+l]
            for j in range(num):
                s += 1+j
            real += s/num
    else:
        pass

print(real)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

max=0
for i in range(len(p)-K+1):
    all=sum(p[i:i+K])
    if all>max:
        max=all
        ind=i

a=0
for i in range(ind,ind+K):
    a+=((p[i]*(p[i]+1))/2)/p[i]

print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = []
c = [sum(p[i:i+k]) for i in range(len(p)-k+1)]
#print(c)
#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()))

c=0
x=0

for i in range(1,n-k+1):
#  print(sum(p[x:x+k]),sum(p[i:i+k]))
  if sum(p[x:x+k])<sum(p[i:i+k]):
    x=i
#print(x)
for i in range(x,x+k):
  c+=((p[i]*(p[i]+1))/2)/p[i]
print(c)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

    p = np.array(p)
    p_prime = p
    p_1 = p + 1
    p = p * p_1 / 2
    p = p / p_prime

    su = 0
    for i in range(0, N-K+1):
        tmp = sum(p[i:(i+K)])
        if tmp > su:
            su = tmp
    print(su)


    return 0

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n,k = map(int,input().split())
d = input().split()
d = [sum(range(1,int(i)+1))/float(i) for i in d]
tmp = 0
result = 0

for i in range(1,n-k+2):
  for j in range(i,i+k):
    tmp += d[j-1]
  if result <= tmp:
    result = tmp
  tmp = 0

print(result)

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):
        e += np.sum(np.arange(int(p[i+j])+1))/int(p[i+j])
    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()))
SUM_P = []
for i in range(N-K+1):
    SUM_P.append(sum(p[i:i+K]))
print((max(SUM_P)+K)/2)

Submission status: Time Limit Exceeded

Solution code:

# N個のサイコロ。隣接するK個のサイコロを選んで振る
N, K = map(int, input().split())
#
# 左から i 番目のサイコロは 1 から pi までの pi 種類の目がそれぞれ等確率で出る
P = list(map(int, input().split()))

max_list = 0
max_num = 0
for i in range(K-1, N+1):
    new_list = P[i-K:i]
    if i == K - 1:
        max_list = new_list
        max_num = sum(new_list)
    else:
        if sum(new_list) > max_num:
            max_list = new_list
            max_num = sum(max_list)

result = 0
for n in max_list:
    result += sum([n for n in range(1, n+1)]) / n

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
ans = []
maxv = max(p)
dp = [i+1 for i in range(maxv+1)]
for i in range(1,maxv+1):
    dp[i] = dp[i-1]+dp[i]
dp = [j/(i+1) for i,j in enumerate(dp)]

def func(n,dp):
    ans = 0
    for i in n:
        ans += dp[i-1]
    return ans

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

Submission status: Time Limit Exceeded

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

arr = []
tmp = 0

for n in P:
  arr.append((n*(n+1)/2)/n)

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

print(tmp)

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())))
sum_list = []
for i in range(N - K + 1):
    sum_list.append(sum(p[i:i+K]))
print((max(sum_list)+K) / 2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

for i in range(len(L)-(K-1)):
  tmp = sum(L[i:i+K])
  #print(tmp)
  if M < tmp:
    M = tmp
    M_IND=i
#print(M_IND)
#for k in range(L[M_IND,M_IND+K])
ANS=0
for i in L[M_IND:M_IND+K]:
  #print(i)
  ex = 0
  p = 1/i
  for x in range(i+1):
      px = p*x
      ex += px
  ANS += ex
print(ANS)

Submission status: Time Limit Exceeded

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

x =0
y = 0
for i in range(n-k+1):
    if x < max(sum(l[i:i+k]),x):
        x = max(sum(l[i:i+k]),x)
        y = i
#print(x,y)

z = 0
for j in range(y,y+k):
    z += (l[j]+1)/2

print(z)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
l = list()
for i in range(len(li)):
    j = i + k
    temp_li = li[i:j]
    s=  sum(temp_li)
    temp_li.insert(0, s)
    t = tuple(temp_li)
    l.append(t)

l.sort(reverse=True)
ans_li = list(l[0])
ans_li.pop(0)

ans = 0
for i in ans_li:
    s = sum(range(1, i+1))
    ans = ans + (s / i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,P = input().split()
N = int(N)
P = int(P)
p = [int(e) for e in input().split()]
result = []
for i in range(len(p)):
    result.append((np.arange(p[i])+1).sum()/p[i])
max_sum = 0
for i in range(len(result)-P+1):
    res_sum = 0
    for j in range(P):
        res_sum = res_sum + result[i+j]
    if res_sum > max_sum:
        max_sum = res_sum
print(max_sum)

Submission status: Time Limit Exceeded

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

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 = 0

for x in range(1,max(sum_p)-K+2):
    ex += x / (max(sum_p)-K+1)

print(ex + K - 1)

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(k,n+1):
  p = l[i-k:i]
  if sum(m) < sum(p):
    m = p
  
print(sum([m[j]*(m[j]+1)/2/m[j] for j in range(k)]))

Submission status: Time Limit Exceeded

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

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

s = 0
max_s = 0

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

    if s > max_s:
        max_s = s

print(max_s)

Submission status: Time Limit Exceeded

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

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

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

print(res)

Submission status: Time Limit Exceeded

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

dices =[]
dicesSum=[]
for i in range(N-K+1):
    l= ps[i:i+K]
    dices.append(l)
    dicesSum.append(sum(l))


max_value = max(dicesSum)
max_index = dicesSum.index(max_value)

exp=0
for p in dices[max_index]:
    exp += 0.5*p +0.5
print(exp)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n,k = list(map(int,input().split()))
num = np.array(list(map(int,input().split())))
max_i = 0

for i in range(n-k+1):
    sum_i = 0
    sum_i = np.sum(num[0:k])
    num = np.delete(num,[0])
    
    if max_i < sum_i:
        max_i = sum_i

print((max_i+k)/2)

Submission status: Time Limit Exceeded

Solution code:
input_line = [int(i) for i in input().split(" ")]
k = input_line[1]

input_line = [(int(i) + 1) / 2 for i in input().split(" ")]

max_excepted_value = []
for i in range(len(input_line) - k + 1):
    max_excepted_value.append(sum(input_line[i: i+ k]))
print(max(max_excepted_value))

Submission status: Time Limit Exceeded

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

kitaichi_list = []

for i in range(N - K + 1):
    kitaichi = 0
    for j in range(K):
        kitaichi += ((0.5 * p[i + j] * (p[i + j] + 1)) / p[i + j])
    kitaichi_list.append(kitaichi)
print(max(kitaichi_list))

Submission status: Time Limit Exceeded

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

ruiseki = [0] * 1001
for i in range(1, 1001):
    ruiseki[i] = ruiseki[i-1] + i

dp = [0] * n
for i in range(k - 1, n):
    for j in range(i + 1 - k, i + 1):
        dp[i] += p[j]

maxs = max(dp)
index = dp.index(maxs)

ans = 0
for l in range(index + 1 - k,index + 1):
    ans += ruiseki[p[l]] / p[l]

print(ans)

Submission status: Time Limit Exceeded

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

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):
    x = sum(p[i:i+k])/2 + 0.5*k 
    if x >= ans:
        ans = x
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

def DE(n):
    return float((n+1)*(n/2)/n)

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    p = list(map(DE,p))
    ls = deque(p[:K])
    ans = sum(ls)
    for i in range(K,N):
        ls.append(p[i])
        ls.popleft()
        ans = max(ans,sum(ls))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np 
N, K = input().split(" ")
ps = input().split(" ")
N, K = int(N), int(K)
ps = np.array([int(p) for p in ps])
p_max = ps.max()
e_list = np.zeros(p_max+1, dtype=np.float64)
for i in range(1, p_max+1):
    e_list[i] = np.mean(np.arange(i) + 1) 
max_e = 0
idx = 0
sum_ps = np.convolve(ps, np.ones(K), mode='valid')
idx = np.argmax(sum_ps)
_ps = ps[idx:idx+K]
e = e_list[_ps].sum()
if e > max_e:
    max_e = e  
print(e)

Submission status: Time Limit Exceeded

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

if len(p) == K:
    kitaiti = 0
    for i in range(len(p)):
        # 一個の数字
        sum = 0
        for j in range(p[i] + 1):
            sum += j
        kitaiti += sum / p[i]
    print(kitaiti)
else:
    max = 0
    max_index = 0
    # 期待値計算に使うリスト 最大のKつ並び
    l = []
    # 最大のKつ並びを見つける
    # iは始点(0スタート)
    # K + i は終点
    for i in range(len(p) - K + 1):
        tmp = sum(p[i:K + i])
        # もしmaxの次だったら、sumの計算が要らない
        if i != 0 & i == max_index + 1:
            if p[i - 1] < p[K + i]:
                max = tmp
                max_index = i
                l = p[i:K + i].copy()    
        elif tmp > max:
            max = tmp
            max_index = i
            l = p[i:K + i].copy()
    
    # 期待値の計算
    kitaiti = 0
    for i in range(len(l)):
        # 一個の数字
        sum = 0
        for j in range(l[i] + 1):
            sum += j
        kitaiti += sum / l[i]
    print(kitaiti)

Submission status: Time Limit Exceeded

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

ans_ind = max([sum(P[i:i+k]) for i in range(len(P)-(k-1))])
ans = (ans_ind + k) * 0.5

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def kitaiti(n):
    return 0.5*n + 0.5

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

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

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    tmp = (sum((p[i:i+K]))+K)*0.5
    if max < tmp :
        max = tmp
print('{:.12f}'.format(max))

Submission status: Time Limit Exceeded

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

for i in range(0, n):
  p[i]=(p[i]+1)*p[i]/(p[i]*2)#p[i]が期待値になった

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

print(m)

Submission status: Time Limit Exceeded

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

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

#ans_lis = [0 for i in range(N*K)]
#for i in range(1, K):
  

anss = [0 for i in range(N-K+1)]
for i in range(0, N-K+1):
  anss[i] = sum(p[i:i+K])
  #ans = sum(p[i:i+K])
  #if ans > max_ans:
  #  max_ans = ans
    
print((max(anss)+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max = -1
ans=0

for i in range(0,n-k+2):
    buf = p[i:i+k]
    tmp = sum(buf)
    if tmp > max:
        ans=0
        max = tmp
        for j in range(len(buf)):
            s_buf = 0
            for l in range(1,buf[j]+1):
                s_buf+=l
            ans += s_buf/buf[j]
            s_buf=0

print(ans)

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

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:
#At coder 2020/2/9 D

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=0.0

if N==K:
    kk=sum(p)
else:
    for ii in range(N-K+1):
        kk=max(kk,sum(p[ii:K+ii]))
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c=0

x=0

for i in range(1,n-k+1):
#  print(sum(p[x:x+k]),sum(p[i:i+k]))
  if sum(p[x:x+k])<sum(p[i:i+k]):
    x=i
#print(x)
for i in range(x,x+k):
  c+=((p[i]*(p[i]+1))/2)/p[i]
print(c)

Submission status: Time Limit Exceeded

Solution code:
def expected_value(x):
    e = 0
    for i in range(1, x+1):
        e += i / x
    return e

n, k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
evs = [0.0]*n
for i in range(n):
    evs[i] = expected_value(p[i])

# initialize
left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))

Submission status: Time Limit Exceeded

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

ans_b = 0
ans_a = 0

for i in range(n-k+1):
    ans_b = sum(p[i:i+k])
    
    if ans_b > ans_a:
        ans_a = ans_b
print((k+ans_a)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
pi = list(map(int, input().split()))
K_sum = []
for i in range(N-K+1):
    K_sum.append(sum(pi[i:i+K])) 
index = K_sum.index(max(K_sum))
array_max = (np.array(pi[index:index+K])-1) *0.5 + 1
print(array_max.sum())

Submission status: Time Limit Exceeded

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

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

maxval = 0

temp = -1

dic = {}

def expectedval(inp):
	if inp in dic:
		return inp
	res = (1 + inp) /2
	return res

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

print(maxval)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    """"ここに今までのコード"""
import sys
input = sys.stdin.readline

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


for i in range(N-K+1):
  if sum(p[i:i+K])>t:
    t=sum(p[i:i+K])
    
print((K+t)/2)
  
      
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

def main():
    n, k = MAP()
    p = LIST()

    ans = 0
    tmp = 0

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

    #print(l)
    k = list(accumulate(range(max(l)+1)))

    for x in l:
        ans += k[x]/x
        
    print(ans)

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

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

    print((max_sum + k) / 2)

resolve()

Submission status: Time Limit Exceeded

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

ma = 0
it = 0
for i in range(N-K+1):
    if ma < sum(List[i:i+K]):
        ma = sum(List[i:i+K])
        it = i
        
answer = sum(list(map(lambda x:(1+x)/2, List[it:it+K])))

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

p_list = np.array(p_list)
b = np.ones(k)/k
p2 = np.convolve(p_list, b, mode='valid')
index = np.argmax(p2)
kitaichi = k/2 + k*p2[index]/2
print(kitaichi)

Submission status: Time Limit Exceeded

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

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

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

print(ans)