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: Wrong Answer

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

pro = 0
for i in range(k):
    pro += arr[i]


ans = pro
for i in range(k,n):
    pro = pro + arr[i]-arr[i-k]
    if arr[i-k] < arr[i]:
        ans = pro

print((ans+k)/2)

Submission status: Wrong Answer

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

s = [0]*N
for i in range(N):
    s[i] = (p[i]+1) / 2
    print(s[i], p[i])
ss = [0]*(N+1)

for i in range(N):
    ss[i+1] = ss[i] + s[i]

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = [int(s) for s in input().split()]
    p = [int(s) for s in input().split()]
    s = sum(p[:K])
    res = 0
    for i in range(1,N):
        if i+K > N:
            break
        s = s + p[i+K-1]
        s = s - p[i-1]
        res = max(s,res)
        
    print((res+K)/2)

main()

Submission status: Wrong Answer

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


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

def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i-1] + l[i]
    return c

c = cumsum(k)

ans = 0

for i in range(N-K):
    t = c[i+K] - c[i]
    if t > ans:
        ans = t

print(ans)

Submission status: Wrong Answer

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

ans = 0
s = 0
for i in range(K):
    s += 1 + Ps[i]

for i in range(K, N):
    s = s - Ps[i-K] + Ps[i]
    ans = ans if ans > s else s

print(ans / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import *
n,k,*p=map(int,open(0).read().split())
a=[(1+i)/2 for i in p]
b=list(accumulate(a))
ans=0
for i in range(n-k):
    ans=max(ans,b[i+k]-b[i])
print(ans)

Submission status: Wrong Answer

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

for i in range(0, n):
    ho_list[i] = sum([i + 1 for i in range(p[i])]) / p[i]

sum_list = [0] * n
sum_list[0] = ho_list[0]
for i in range(1, n):
    sum_list[i] = sum_list[i - 1] + ho_list[i]

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

Submission status: Wrong Answer

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

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


p2 = []

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

ans = 0
tmp = 0
#p3 = []
for i in range(n):
    if(i<k):
        tmp = tmp + p2[i]
    else:
        tmp = tmp - p2[i-k] + p2[i]
        ans = max(ans,tmp)
    #p3.append(tmp)

#print(p2)
#print(p3)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

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

P.sort(reverse=True)

sk = sum(P[:K])
ans = sk / 2. + K / 2.

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for i in range(m):
    ans += (1/2)*(a[i]+1)

print(ans)

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
y = [i/2+0.5 for i in y]
max_value = 0
for i in range(0, x[0]-x[1]+1):
  value = sum(y[i:i+4])
  max_value = max(max_value, value)
print(max_value)

Submission status: Wrong Answer

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

pro = 0
for i in range(k):
    pro += arr[i]


ans = pro
for i in range(k,n):
    pro = pro + arr[i]-arr[i-k]
    if arr[i-k] < arr[i]:
        ans = pro

print("{:.12g}".format((ans+k)/2))

Submission status: Wrong Answer

Solution code:
''' Hey stalker :) '''
INF = 10**10
def main():
    #print = out.append
    ''' Cook your dish here! '''
    n, k = get_list()
    li = get_list()
    li.sort(reverse=True)
    sm = sum(li[:k])
    print((sm+k)/2)



''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

tmp = 0
for i in range(K):
    tmp += P[i]
ans = P[i]

for i in range(K, N):
    tmp += P[i] - P[i - K]
    ans = max(ans, tmp)

print (ans)

Submission status: Wrong Answer

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

mxidx = 0
mx = 0
tot=0
for i in range(k):
    tot+=p[i]
mx=tot
for i in range(k,n):
    tot+=p[i]-p[i-k]
    if tot>mx:
        mxidx=i-k+1

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*(n+1)
for i in range(n):
    B[i+1]=B[i]+A[i]
for i in range(1,n-k+1):
    ans=max(ans,B[i+k]-B[i])
print((ans+k)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=[(int(i)+1)/2 for i in input().split()]
left = 0
right = K
max_=sum(P[:K])
ans=0
for _ in range(N-K):
    ans=max(max_,max_ - P[left] + P[right])
    max_=max_ - P[left] + P[right]
    left += 1
    right += 1
print(ans)

Submission status: Wrong Answer

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

pro = 0
for i in range(k):
    pro += (arr[i]+1)/2


ans = pro
for i in range(k,n):
    pro = pro + (arr[i]-arr[i-k])/2
    if arr[i-k] < arr[i]:
        ans = pro

print("{:.12g}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
def main():

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

    ex = [0]
    for x in p:
        ex.append(ex[-1] + 1/x * (sum(list(range(1, x+1)))))

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

    print(ans)

main()

Submission status: Time Limit Exceeded

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

ex = [0]
for x in p:
    ex.append(ex[-1] + 1/x * (sum(list(range(1, x+1)))))

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

print(ans)

Submission status: Time Limit Exceeded

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

ex = []
for x in p:
    ex.append(1/x * (sum(list(range(1, x+1)))))

cs = [0]
for x in ex:
    cs.append(cs[-1]+x)

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

print(ans)

Submission status: Time Limit Exceeded

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

ex = []
for x in p:
    ex.append(1/x * (sum(list(range(1, x+1)))))

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

list2=[]
list3=[]
list4=[]

for j in list1:
    w=(1+j)/2
    list2.append(w)

k=0
while k<=N:
    list3.append(sum(list2[0:k+1]))
    k=k+1

i=0
list4.append(list3[i+K-1])
i=1
while i<=N-K:
    list4.append(list3[i+K-1]-list3[i-1])
    i=i+1

list4.sort()
p=list4[-1]

print(str(p))

Submission status: Time Limit Exceeded

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

list2=[]
list3=[]


for j in list1:
    w=(1+j)/2
    list2.append(w)

u=0
l=0
while u<=N-K:
    l=sum(list2[u:u+K])
    list3.append(l)
    u=u+1

list3.sort()
p=list3[-1]

print(str(p))

Submission status: Time Limit Exceeded

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

def want(x):
    s=1
    y=0
    while s<=x:
        y=y+s/x
        s=s+1
    return y

list2=[]
list3=[]

for j in list1:
    list2.append(want(j))

u=0
l=0
while u<=N-K:
    l=sum(list2[u:u+K])
    list3.append(l)
    u=u+1

list3.sort()
p=list3[-1]

print(str(p))

Submission status: Time Limit Exceeded

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

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

ans = (d_max + k)/2
print(ans)

Submission status: Time Limit Exceeded

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

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

ans = (d_max + k)/2
print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
U = [0]*n

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

ans = sum(U[:k])

for j in range(1, n-k+1):
    t = 0
    for i in range(j, j+k):
        t += U[i]
    if ans < t:
        ans = t
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
U = [0]*n

def s(x):
    t = 0
    for i in range(x):
        t += i+1
    return t/x

for i in range(n):
    U[i] = s(P[i])

ans = 0
for i in range(0, k):
    ans += U[i]

for j in range(1, n-k+1):
    t = 0
    for i in range(j, j+k):
        t += U[i]
    if ans < t:
        ans = t
print(ans)

Submission status: Time Limit Exceeded

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

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

ans = 0
for i in range(n - k + 1):
    tmp = 0
    for j in range(i, i + k):
        tmp += ev(p[j])
    if ans <= tmp:
        ans = tmp
    #print(ans, i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from numpy import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = (N-K+1)*[0]

for n in range(N-K+1):
  Q[n] = sum(P[n:n+K])

R = argmax(Q)
print(0.5*(sum(P[R:R+K])+K))

Submission status: Time Limit Exceeded

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

E = []

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

l = N - K + 1
tnt = 0
ans = 0
j = 0
k = K

while k <= N:
    tnt = sum(E[j:k])
    ans = max(ans, tnt)
    j += 1
    k += 1

print(ans)

Submission status: Time Limit Exceeded

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

l = N - K + 1
ans = 0
tnt = 0

for i in range(l):
    for j in range(K):
        tnt += (P[i+j]+1)/2
        ans = max(ans, tnt)
    tnt = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:

def main():
    n, k = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    u = []
    v = []
    for i in range(n-k+1):
        u.append(sum(p[i:i+k]))
    x = u.index(max(u))
    for i in range(k):
        v.append(p[x+i])
    a=0
    for i in range(k):
        a += 1+0.5*(v[i]-1)
    print(a)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

def main():
    n, k = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    ans = []
    for i in range(n-k+1):
        x = p[i:i+k]
        if sum(ans) < sum(x):
            ans = x
    a=0
    for i in range(k):
        a += 1+0.5*(ans[i]-1)
    print(a)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

def main():
    n, k = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    ans = []
    for i in range(n-k+1):
        x = p[i:i+k]
        if sum(ans) < sum(x):
            ans = x
    a=0
    for i in range(k):
        b=0
        for j in range(ans[i]):
            b += j+1
        a += b/ans[i]
    print(a)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
q = [(x+1)/2 for x in p]
ans = 0

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

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
  arr.append(sum(q[i:i+k]))
  
print(max(arr))

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
  cnt = 0
  for j in range(i, i+k):
    cnt += (p[j] + 1)/2
    
  arr.append(cnt)
  
print(max(arr))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def expectationF(num):
  exp = 0
  for i in range(1,num+1):
    exp += i/num
  return exp

res = 0
mid = 0
for i in range(N-K+1):
  mid=0
  for j in range(K):
    mid += expectationF(List[i+j])
  res = max(res,mid)
print(res)

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

Submission status: Time Limit Exceeded

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

    tmp1_lst = []
    for i in range(k):
        tmp1_lst.append(p_lst[i])

    for i in range(n - k + 1):
        tmp2_lst = p_lst[i:i + k]
        if sum(tmp1_lst) < sum(tmp2_lst):
            tmp1_lst = tmp2_lst

    maximum = 0
    for i in range(k):
        number = tmp1_lst[i]
        maximum += number * (number + 1) / 2 / number

    print(maximum)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    P = map(int, input().split())
    E = [(p+1)/2 for p in P]
    V = [sum(E[i:i+K]) for i in range(N-K+1)]
    print(max(V))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
for i in range(N-K+1):
  ans[i]=sum(p[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()))

for i in range(N):
  p[i]=(1+p[i])/2
  
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:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n, k = i_map()
    p = i_list()

    l = []
    dic = {}

    sowa = [0]
    for i in range(1,1001):
        sowa.append(sowa[i-1]+i)

    for i in p:
        l.append(sowa[i]/i)

    ans = 0
    for i in range(n-k+1):
        ans = max(ans,sum(l[i:i+k]))
    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()))

lis=[(i+1)/2 for i in l]
ans=0

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

Submission status: Time Limit Exceeded

Solution code:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

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

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



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def main():
    import numpy as np

    def expected_val(limit):
        return sum(range(1 + limit)) / limit

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

    lst = np.zeros(N + 1)
    res = 0
    for i in range(N):
        res += expected_val(P[i])
        lst[i + 1] = res
    print(np.max(lst[K:] - lst[:N - K + 1]))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

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

    ans = 0
    for i in range(N - K + 1):
        res = 0
        for k in range(K):
            res += expected_val(P[i + k])
        ans = max(ans, res)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

print((t+K)/2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

print(t)

Submission status: Time Limit Exceeded

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

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

S = []
for i in range(N-K+1):
    s = sum(E[i:i+K])
    S.append(s)

print(max(S))

Submission status: Time Limit Exceeded

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

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

ACC = 1
for p in P:
    ACC *= p

R = 0
for p in P[:K]:
    R += numerator(p) * ACC // p

max_value = R
for i in range(N-K):
    R += numerator(P[i+K]) * ACC // P[i+K] - numerator(P[i]) * ACC // P[i]
    max_value = max(max_value, R)
print(max_value / ACC)

Submission status: Time Limit Exceeded

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

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

ACC = 1
for p in P:
    ACC *= p

R = 0
for p in P[:K]:
    R += numerator(p) * ACC // p

max_value = R
for i in range(N-K):
    R += numerator(P[i+K]) * ACC // P[i+K] - numerator(P[i]) * ACC // P[i]
    max_value = max(max_value, R)
print(max_value / ACC)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
ps = list(map(int,input().split()))
su = 0
ind = 0
for i in range(N-K+1):
    ksum = sum(ps[i:i + K])
    if ksum > su:
        ind = i
        su = ksum
ki = 0

for i in range(ind, ind+K):
    ki += (ps[i]*(ps[i]+1))/2/ps[i]
print(ki)

Submission status: Time Limit Exceeded

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

nums = [0]*n
for i in range(n): nums[i] = sum(range(1, p[i]+1))/p[i]

ans = sum(nums[:k])
t = sum(nums[:k])
for i in range(k,n):
  t += nums[i] - nums[i-k]
  if ans < t: ans = t
print(ans)

Submission status: Time Limit Exceeded

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

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

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else: print(ans)

Submission status: Time Limit Exceeded

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

li = [0] * N
for i in range(N):
  for j in range(1, p[i] + 1):
    li[i] += j / p[i]

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
max = 0
idx = 0
for i in range(len(p) - k + 1):
	if sum(p[i:i+k]) > max:
		max = sum(p[i:i+k])
		idx = i
lst = p[idx:idx+k]

total_tasu = 0
total_kake = reduce(lambda a, b: a*b, lst)
for i, v in enumerate(lst):
	kake = total_kake / v
	for j in range(1, v + 1):
		total_tasu += j * kake
print(total_tasu/total_kake)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
max = 0
idx = 0
for i in range(len(p) - k + 1):
	if sum(p[i:i+k]) > max:
		max = sum(p[i:i+k])
		idx = i
lst = p[idx:idx+k]

total = 0
shokei = 0
for i, v in enumerate(lst):
	kake = lst[0:i]
	if i != k - 1:
		kake += lst[i+1:i+k+1]
	shokei = reduce(lambda a, b: a*b, kake, 1)
	for j in range(1, v + 1):
		total += j * shokei
waru = reduce(lambda a, b: a*b, lst)
print(total/waru)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def Ex(x):
    return (1/2)*(x+1)
N,K = map(int,input().split())
plist = list(map(int,input().split()))
Alist = [0]*N
Ans = sum(plist[0:K])
An = [0,K]
for j in range(0,N-K+1):
    if Ans != max(Ans,sum(plist[j:j+K])):
        Ans = max(Ans,sum(plist[j:j+K]))
        An = [j,j+K]
Answer = 0
for i in plist[An[0]:An[1]]:
    Answer += Ex(i)
print(Answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def Ex(x):
    return (1/2)*(x+1)
N,K = map(int,input().split())
plist = list(map(int,input().split()))
Alist = [0]*N
for i in range(N):
    Alist[i] = Ex(plist[i])
Ans = sum(Alist[0:K])
for j in range(0,N-K+1):
    Ans = max(Ans,sum(Alist[j:j+K]))
print(Ans)

Submission status: Time Limit Exceeded

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

kitai = [0]*1000
tmp = 0
for i in range(1000):
  tmp += i+1
  kitai[i] = tmp/(i+1)
#print(kitai)
  

window = deque([kitai[p[i]-1] for i in range(k)])
ans = sum(window)
for i in range(n-k+1):
  #print(window)
  window.popleft()
  window.append(kitai[p[i+k-1]-1])
  ans = max(sum(window),  ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:

n,k=[int(i) for i in input().split()]
p=[(int(i)+1)/2 for i in input().split()]


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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,k=[int(i) for i in input().split()]
p=list((np.array([int(i) for i in input().split()])+1)/2)


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

Submission status: Time Limit Exceeded

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

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

probability=[]
sums=[0]
total=0
for i in range(N):
    num=0
    prob=1/P[i]
    for j in range(1,P[i]+1):
        num+=j*prob
    probability.append(num)
    total+=num
    sums.append(total)

ans=0
for j in range(N-K+1):
    if ans<sums[j+K]-sums[j]:
        ans=sums[j+K]-sums[j]

print('{:.012f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    p = LI()
    for i,x in enumerate(p):
        if x%2 == 0:
            x = x//2+0.5
        else:
            x = x//2+1
        p[i] = x
    
    ans = 0
    for i in range(n-k+1):
        lst = p[i:i+k]
        # print(p,lst)
        ans = max(ans,sum(lst))
    
    print(ans)
main()

Submission status: Time Limit Exceeded

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

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

probability=[]
for i in range(N):
    num=0
    prob=1/P[i]
    for j in range(1,P[i]+1):
        num+=j*prob
    probability.append(num)

max_num=0
for i in range(N-K+1):
    sum_num=0
    for j in range(i,i+K):
        sum_num+=probability[j]
    if max_num<sum_num:
        max_num=sum_num
print('{:.012f}'.format(max_num))

Submission status: Time Limit Exceeded

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

p = [int(x) for x in input().split()]

p_kitaiti=[]

for i in p:
    goukei=(i*(i+1))/2
    p_kitaiti.append(goukei/i)

ans=0

for i in range(len(p_kitaiti)-k+1):
    zantei=sum(p_kitaiti[i:i+k])
    ans=max(ans,zantei)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
p = list(map(int, input().split()))
l = []
for i in range(n-k+1):
    t = 0
    for h in range(k):
        for j in range(1,p[i+h]+1):
            t += (j/p[i+h])
    l.append(t)
l.sort()
print(max(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


def CalculateExpectedValu(n):
    bunbo = 1 / n
    ans = 0

    for i in range(1,n+1):
        ans = ans + (i*bunbo)

    return ans

number = 0
CumulativeSum = [0]

for i in P:
    number = number + CalculateExpectedValu(i)
    CumulativeSum.append(number)

ans = 0



for i in range(0 , (len(CumulativeSum)-K)):
    tmpans = CumulativeSum[i+K] - CumulativeSum[i]
    ans = max(ans, tmpans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
ka=[0]+[kai[i]/i for i in range(1,len(kai))]

mx=0
for i in range(len(li)-k+1):
  x=li[i:i+k]
  ans=0
  for j in x:
    ans+=ka[j]
  mx=max(ans,mx)
print(mx)

Submission status: Time Limit Exceeded

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

mx=0
for i in range(len(li)-k+1):
  ans=0
  x=li[i:i+k]

  for j in x:
    ans+=kai[j]/j
  mx=max(ans,mx)
print(mx)

Submission status: Time Limit Exceeded

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

ans = []

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

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