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=list(map(int,input().split()))
p=list(map(int,input().split()))
counter=0
ans=0
for i in range(len(p)-K+1):
    count=0
    for j in range(K):
        count+=p[i+j]
    if counter<=count:
        counter=count
        ans=i
p2=[]
for i in range(K):
    p2.append(p[ans+i])
p3=[]
for i in p2:
    p3.append((sum(range(1,i+1))/i))
print(sum(p3))

Submission status: Time Limit Exceeded

Solution code:
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
counter=0
ans=0
for i in range(len(p)-K+1):
    count=0
    for j in range(K):
        count+=p[i+j]
    if counter<=count:
        counter=count
        ans=i
p2=[]
for i in range(K):
    p2.append(p[ans+i])
p3=[]
from itertools import accumulate
for i in p2:
    p3.append((sum(range(1,i+1))/i))
print(sum(p3))

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

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

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

R = [0] * (N - K + 1)
for i in range(N - K + 1):
    R[i] += sum(Q[i:i + K])

print(max(R))

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

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

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

R = [0] * (N - K + 1)
for i in range(N - K + 1):
    for j in range(i, i + K):
        R[i] += Q[j]

print(max(R))

Submission status: Time Limit Exceeded

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

ans = -1
for i in range(n):
    if i + k > n: break
    ans = max(ans, sum(pe_list[i:i+k]))
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

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

ans = 0
for p_ in p[max_[1]:max_[2]]:
    ans += 1 + (p_ - 1) * 0.5

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

Submission status: Time Limit Exceeded

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

averages = []
for _ in range(N):
    averages.append((1 + p[_])/2)
#print(averages)

sumlist = []
for i in range(0, N-K+1):
    Sum = 0
    for j in range(K):
        Sum += averages[i+j]
    sumlist.append(Sum)
#print(sumlist)

print(max(sumlist))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

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

print((sum(p[:ans_i+k]) - sum(p[:ans_i]) + k)/2)

Submission status: Time Limit Exceeded

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

p = list(map(int,input().split()))
m=0
for i in range(n-k+1):
    m = max(m,sum(p[i:i+k]))

for i in range(n-k+1):
    if sum(p[i:i+k])==m:
        ans_i = i
        break
ans=0
for i in range(ans_i,ans_i+k):
    ans += (p[i]+1)/2
   
print(ans)

Submission status: Time Limit Exceeded

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

a = i = j = count = ans = 0

while k <= n:
    total = 0
    while i < k:
        tmp = 0
        for j in range(p[i]):
            tmp += j+1
        tmp = float(tmp/p[i])
        total += tmp
        i += 1
    if(total > ans):
        ans = total
    count += 1
    k += 1
    i = count
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N, K = map(int, input().split())
cnt = [int(x) * 0.5 + 0.5 for x in input().split()]

ans = (sum(cnt[x:x+K]) for x in range(N-K+1))
print(reduce(max, ans))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
cnt = [int(x) * 0.5 + 0.5 for x in input().split()]

ans = [sum(cnt[x:x+K]) for x in range(N-K+1)] #if len(cnt[x:x+K]) == K]
print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
E = [(p + 1)/2 for p in P]
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum(E[i: K+i]))
print(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] = p_[i]/2 +0.5

cnt,res =0,[]
for i in range(n-k+1):
    cnt = sum(p_[:i+k]) - sum(p_[:i])
    res.append(cnt)

print(max(res))

Submission status: Time Limit Exceeded

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

def calc_ex(x):
    return  x/2 + 0.5
p_ = list(map(calc_ex,p_))

cnt,res =0,[]
for i in range(n-k+1):
    cnt = sum(p_[:i+k]) - sum(p_[:i])
    res.append(cnt)

print(max(res))

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)
    l.append(temp_li)

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:
(N, K) = list(map(int,input().split()))
P = list(map(int, input().split()))

def max_expected(L, K):
  length = len(L)
  if (length < K):
    return -1
  if (length == K):
    return (sum(L) + K) / 2
  mid = length // 2
  s_left = max_expected(L[0:mid], K)
  s_right = max_expected(L[mid:], K)
  offset = 0

  if (mid - K + 1 < 0):
    offset = - (mid - K + 1)
  end_offset = 0
  if (mid + K - 1 >= length):
    end_offset = mid + K - 1 - length
  max_p = sum(L[mid - K + 1 + offset:mid + 1 + offset])
  for i in range(mid - K + 1 + offset + 1, mid - end_offset):
    j = sum(L[i:(i + K)])
    if max_p < j:
      max_p = j
  
  return max((max_p + K) / 2, s_left, s_right)
print("{}".format(max_expected(P, K)))

Submission status: Time Limit Exceeded

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

def max_expected(L, K):
  length = len(L)
  if (length < K):
    return -1
  if (length == K):
    return (sum(L) + K) / 2
  mid = length // 2
  s_left = max_expected(L[0:mid], K)
  #print("left array:{}, max: {}".format(L[0:mid], s_left))
  s_right = max_expected(L[mid:], K)
  #print("right array:{}, max: {}".format(L[mid:], s_right))
  offset = 0

  if (mid - K + 1 < 0):
    offset = - (mid - K + 1)
  end_offset = 0
  if (mid + K - 1 >= length):
    end_offset = mid + K - 1 - length
  max_p = sum(L[mid - K + 1 + offset:mid + 1 + offset])
  for i in range(mid - K + 1 + offset, mid - end_offset):
    j = sum(L[i:(i + K)])
    #print("{}[{}]..{}[{}]: {}".format(L[i], i, L[i + K - 1], i + K - 1, j))
    if max_p < j:
      max_p = j
  #print("mid: {}".format((max_p + K) / 2));
  
  return max((max_p + K) / 2, s_left, s_right)
print("{}".format(max_expected(P, K)))

Submission status: Time Limit Exceeded

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

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

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

for i in range(n-k+1):
    if sum(p[i:i+k])==m:
        ans_i = i
        break
ans=0
for i in range(ans_i,ans_i+k):
    num = p[i]
    den = p[i]*(p[i]+1)/2
    ans += den/num
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

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

p = list(map(int,input().split()))
p_p = [0 for _ in range(n)]

"""
for i in range(n):
    p_p[i] = reduce(lambda a,b:a+b, range(1,p[i]+1))
    p_p[i] /= p[i]
"""

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

for i in range(n-k+1):
    if sum(p[i:i+k])==m:
        ans_i = i
        break
ans=0
for i in range(ans_i,ans_i+k):
    num = p[i]
    den = reduce(lambda a,b:a+b, range(1,p[i]+1))
    ans += den/num
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

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

p = list(map(int,input().split()))
p_p = [0 for _ in range(n)]

for i in range(n):
    p_p[i] = reduce(lambda a,b:a+b, range(1,p[i]+1))
    p_p[i] /= p[i]

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n, k = map(int, stdin.readline().split())
    p = list(map(int, stdin.readline().split()))

    sp = [0] * 1001

    for i in range(1, 1001):
        sp[i] = sum(range(i + 1)) / i

    max = 0
    max_index = 0

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

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

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n, k = map(int, stdin.readline().split())
    p = list(map(int, stdin.readline().split()))

    sp = [0] * 1001

    for i in range(1, 1001):
        sp[i] = sum(range(i + 1)) / i

    max = 0
    max_index = 0

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

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

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n, k = map(int, stdin.readline().split())
    p = list(map(int, stdin.readline().split()))

    sp = [0] * n

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

    max = 0.0

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

    print(max)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Time Limit Exceeded

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

N = NK[0]
K = NK[1]
tmp_list = Ps[0:K]

for i in range(N-K+1):
    if (sum(tmp_list) < sum(Ps[i:i+K])):
        tmp_list = Ps[i:i+K]
        

print((sum(tmp_list)/2.0) + (K/2.0))

Submission status: Time Limit Exceeded

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

Ev_list = [(P+1)/2 for P in Ps]
N = NK[0]
K = NK[1]

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

print(max(connected_value))

Submission status: Time Limit Exceeded

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

p_=[]
for i in range(len(p)):
  p_.append((1+p[i])/2)
ans=0
for i in range(N+2-K):
  s=sum(p_[i:i+K])
  ans=max(ans,s)
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(0, N-K+1):
    tmp = sum(P[i:i+K])
    if tmp > ans:
        ans = tmp
    
print((ans+K)/2)

Submission status: Time Limit Exceeded

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

EMax = 0
for l in range(N - K + 1):
    t = 0
    testlist = []
    for t in range(K):
        testlist.append((1 + int(plist[t + l])) / 2)
    # print(testlist)
    S = sum(testlist)
    if S > EMax:
        EMax = S

print(EMax)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
plist = input().split()
exlist = []
Sumlist = []

for i in plist:

    exp = (1 + int(i)) * int(i) / 2 / int(i)
    exlist.append(exp)
# print(exlist)

EMax = 0
for l in range(N - K + 1):
    t = 0
    testlist = []
    for t in range(K):
        testlist.append(exlist[t + l])
    # print(testlist)
    S = sum(testlist)
    if S > EMax:
        EMax = S

print(EMax)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
plist = input().split()
exlist = []
Sumlist = []

for i in plist:
    sm = 0
    j = 0
    while j <= int(i):
        sm += j
        j += 1
    # print(sm)
    exp = sm / int(i)
    exlist.append(exp)
# print(exlist)

EMax = 0
for l in range(N - K + 1):
    t = 0
    testlist = []
    for t in range(K):
        testlist.append(exlist[t + l])
    # print(testlist)
    S = sum(testlist)
    if S > EMax:
        EMax = S

print(EMax)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
plist = input().split()
exlist = []
Sumlist = []

for i in plist:
    sm = 0
    j = 0
    while j <= int(i):
        sm += j
        j += 1
    # print(sm)
    exp = sm / int(i)
    exlist.append(exp)
# print(exlist)


for l in range(N - K + 1):
    t = 0
    testlist = []
    for t in range(K):
        testlist.append(exlist[t + l])
    # print(testlist)
    S = sum(testlist)
    Sumlist.append(S)
# print(Sumlist)
print(max(Sumlist))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
cnt = [int(x) * 0.5 + 0.5 for x in input().split()]

ans = [sum(cnt[x:x+K]) for x in range(N+1) if len(cnt[x:x+K]) == K]
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
cnt = np.array([int(x) * 0.5 + 0.5 for x in input().split()])

ans = np.array([sum(cnt[x:y]) for x, y in zip(range(0, N-K+1), range(K, N+1))])
print(ans.max())

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
cnt = [int(x) * 0.5 + 0.5 for x in input().split()]

ans = [sum(cnt[x:y]) for x, y in zip(range(0, N-K+1), range(K, N+1))]
print(max(ans))

Submission status: Time Limit Exceeded

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

cnt = [x * 0.5 + 0.5 for x in p]
ans = [sum(cnt[x:y]) for x, y in zip(range(0, N-K+1), range(K, N+1))]

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
cnt = list(map(lambda x : x * 0.5 + 0.5, p))

ans = [sum(cnt[x:y]) for x, y in zip(range(0, N-K+1), range(K, N+1))]
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
cnt = list(map(lambda x : x * 0.5 + 0.5, p))

ans = []
x = 0
y = K
while len(cnt[x:y]) == K:
    ans.append(sum(cnt[x:y]))
    x += 1
    y += 1

print(max(ans))

Submission status: Time Limit Exceeded

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

cnt = {}
x = 0
y = K
while len(p[x:y]) == K:
    cnt[x] = sum(p[x:y])
    x += 1
    y += 1

for x, v in cnt.items():
    if v == max(cnt.values()):
        output = p[x:x+K]
        print(sum(list(map(lambda x : x * 0.5 + 0.5, output))))
        sys.exit(0)

Submission status: Time Limit Exceeded

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

cnt = {}
x = 0
y = K
while len(p[x:y]) == K:
    cnt[x] = sum(p[x:y])
    x += 1
    y += 1

for x, v in cnt.items():
    if v == max(cnt.values()):
        output = p[x:x+K]

ans = 0
for o in output:
    ans += sum(range(o+1))/o

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def expect(p, i, j):
    sum=0
    for l in range(j-i+1):
        sum += (1 + p[i + l]) / 2
    return sum

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

for j in range(n-k+1):
    tmp = expect(p, j, k+j-1)
    if max < tmp: max = tmp
print(max)

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

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

total = 0
for i in range(mx_i, mx_i + K):
    for j in range(1, P[i] + 1):
        total += j / P[i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K=map(int, input().split())
    A = list(map(int, input().split()))
    B=0
    for i in range(N-K+1):
        S = (sum(A[i:i+K])+K)/2
        if B<S:
            B=S
    print(B)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

ma = 0

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

Submission status: Time Limit Exceeded

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

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

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

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

print(max(sum_equity))

Submission status: Time Limit Exceeded

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

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

equity=[n*(n+1)/2*(1/n) for n in p]

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

print(max(sum_equity))

Submission status: Time Limit Exceeded

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

pn = list(map(lambda x: sum([i for i in range(1, x+1)]) / x, pn))

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

print(ans)

Submission status: Time Limit Exceeded

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

pn = list(map(lambda x: sum([i for i in range(1, x+1)]) / x, pn))

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
list = [0] * k
evlist = [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0,
          11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 14.5, 15.0, 15.5, 16.0, 16.5, 17.0, 17.5, 18.0, 18.5, 19.0, 19.5, 20.0,
          20.5, 21.0, 21.5, 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, 27.0, 27.5, 28.0, 28.5, 29.0,
          29.5, 30.0, 30.5, 31.0, 31.5, 32.0, 32.5, 33.0, 33.5, 34.0, 34.5, 35.0, 35.5, 36.0, 36.5, 37.0, 37.5, 38.0,
          38.5, 39.0, 39.5, 40.0, 40.5, 41.0, 41.5, 42.0, 42.5, 43.0, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0,
          47.5, 48.0, 48.5, 49.0, 49.5, 50.0, 50.5, 51.0, 51.5, 52.0, 52.5, 53.0, 53.5, 54.0, 54.5, 55.0, 55.5, 56.0,
          56.5, 57.0, 57.5, 58.0, 58.5, 59.0, 59.5, 60.0, 60.5, 61.0, 61.5, 62.0, 62.5, 63.0, 63.5, 64.0, 64.5, 65.0,
          65.5, 66.0, 66.5, 67.0, 67.5, 68.0, 68.5, 69.0, 69.5, 70.0, 70.5, 71.0, 71.5, 72.0, 72.5, 73.0, 73.5, 74.0,
          74.5, 75.0, 75.5, 76.0, 76.5, 77.0, 77.5, 78.0, 78.5, 79.0, 79.5, 80.0, 80.5, 81.0, 81.5, 82.0, 82.5, 83.0,
          83.5, 84.0, 84.5, 85.0, 85.5, 86.0, 86.5, 87.0, 87.5, 88.0, 88.5, 89.0, 89.5, 90.0, 90.5, 91.0, 91.5, 92.0,
          92.5, 93.0, 93.5, 94.0, 94.5, 95.0, 95.5, 96.0, 96.5, 97.0, 97.5, 98.0, 98.5, 99.0, 99.5, 100.0, 100.5, 101.0,
          101.5, 102.0, 102.5, 103.0, 103.5, 104.0, 104.5, 105.0, 105.5, 106.0, 106.5, 107.0, 107.5, 108.0, 108.5,
          109.0, 109.5, 110.0, 110.5, 111.0, 111.5, 112.0, 112.5, 113.0, 113.5, 114.0, 114.5, 115.0, 115.5, 116.0,
          116.5, 117.0, 117.5, 118.0, 118.5, 119.0, 119.5, 120.0, 120.5, 121.0, 121.5, 122.0, 122.5, 123.0, 123.5,
          124.0, 124.5, 125.0, 125.5, 126.0, 126.5, 127.0, 127.5, 128.0, 128.5, 129.0, 129.5, 130.0, 130.5, 131.0,
          131.5, 132.0, 132.5, 133.0, 133.5, 134.0, 134.5, 135.0, 135.5, 136.0, 136.5, 137.0, 137.5, 138.0, 138.5,
          139.0, 139.5, 140.0, 140.5, 141.0, 141.5, 142.0, 142.5, 143.0, 143.5, 144.0, 144.5, 145.0, 145.5, 146.0,
          146.5, 147.0, 147.5, 148.0, 148.5, 149.0, 149.5, 150.0, 150.5, 151.0, 151.5, 152.0, 152.5, 153.0, 153.5,
          154.0, 154.5, 155.0, 155.5, 156.0, 156.5, 157.0, 157.5, 158.0, 158.5, 159.0, 159.5, 160.0, 160.5, 161.0,
          161.5, 162.0, 162.5, 163.0, 163.5, 164.0, 164.5, 165.0, 165.5, 166.0, 166.5, 167.0, 167.5, 168.0, 168.5,
          169.0, 169.5, 170.0, 170.5, 171.0, 171.5, 172.0, 172.5, 173.0, 173.5, 174.0, 174.5, 175.0, 175.5, 176.0,
          176.5, 177.0, 177.5, 178.0, 178.5, 179.0, 179.5, 180.0, 180.5, 181.0, 181.5, 182.0, 182.5, 183.0, 183.5,
          184.0, 184.5, 185.0, 185.5, 186.0, 186.5, 187.0, 187.5, 188.0, 188.5, 189.0, 189.5, 190.0, 190.5, 191.0,
          191.5, 192.0, 192.5, 193.0, 193.5, 194.0, 194.5, 195.0, 195.5, 196.0, 196.5, 197.0, 197.5, 198.0, 198.5,
          199.0, 199.5, 200.0, 200.5, 201.0, 201.5, 202.0, 202.5, 203.0, 203.5, 204.0, 204.5, 205.0, 205.5, 206.0,
          206.5, 207.0, 207.5, 208.0, 208.5, 209.0, 209.5, 210.0, 210.5, 211.0, 211.5, 212.0, 212.5, 213.0, 213.5,
          214.0, 214.5, 215.0, 215.5, 216.0, 216.5, 217.0, 217.5, 218.0, 218.5, 219.0, 219.5, 220.0, 220.5, 221.0,
          221.5, 222.0, 222.5, 223.0, 223.5, 224.0, 224.5, 225.0, 225.5, 226.0, 226.5, 227.0, 227.5, 228.0, 228.5,
          229.0, 229.5, 230.0, 230.5, 231.0, 231.5, 232.0, 232.5, 233.0, 233.5, 234.0, 234.5, 235.0, 235.5, 236.0,
          236.5, 237.0, 237.5, 238.0, 238.5, 239.0, 239.5, 240.0, 240.5, 241.0, 241.5, 242.0, 242.5, 243.0, 243.5,
          244.0, 244.5, 245.0, 245.5, 246.0, 246.5, 247.0, 247.5, 248.0, 248.5, 249.0, 249.5, 250.0, 250.5, 251.0,
          251.5, 252.0, 252.5, 253.0, 253.5, 254.0, 254.5, 255.0, 255.5, 256.0, 256.5, 257.0, 257.5, 258.0, 258.5,
          259.0, 259.5, 260.0, 260.5, 261.0, 261.5, 262.0, 262.5, 263.0, 263.5, 264.0, 264.5, 265.0, 265.5, 266.0,
          266.5, 267.0, 267.5, 268.0, 268.5, 269.0, 269.5, 270.0, 270.5, 271.0, 271.5, 272.0, 272.5, 273.0, 273.5,
          274.0, 274.5, 275.0, 275.5, 276.0, 276.5, 277.0, 277.5, 278.0, 278.5, 279.0, 279.5, 280.0, 280.5, 281.0,
          281.5, 282.0, 282.5, 283.0, 283.5, 284.0, 284.5, 285.0, 285.5, 286.0, 286.5, 287.0, 287.5, 288.0, 288.5,
          289.0, 289.5, 290.0, 290.5, 291.0, 291.5, 292.0, 292.5, 293.0, 293.5, 294.0, 294.5, 295.0, 295.5, 296.0,
          296.5, 297.0, 297.5, 298.0, 298.5, 299.0, 299.5, 300.0, 300.5, 301.0, 301.5, 302.0, 302.5, 303.0, 303.5,
          304.0, 304.5, 305.0, 305.5, 306.0, 306.5, 307.0, 307.5, 308.0, 308.5, 309.0, 309.5, 310.0, 310.5, 311.0,
          311.5, 312.0, 312.5, 313.0, 313.5, 314.0, 314.5, 315.0, 315.5, 316.0, 316.5, 317.0, 317.5, 318.0, 318.5,
          319.0, 319.5, 320.0, 320.5, 321.0, 321.5, 322.0, 322.5, 323.0, 323.5, 324.0, 324.5, 325.0, 325.5, 326.0,
          326.5, 327.0, 327.5, 328.0, 328.5, 329.0, 329.5, 330.0, 330.5, 331.0, 331.5, 332.0, 332.5, 333.0, 333.5,
          334.0, 334.5, 335.0, 335.5, 336.0, 336.5, 337.0, 337.5, 338.0, 338.5, 339.0, 339.5, 340.0, 340.5, 341.0,
          341.5, 342.0, 342.5, 343.0, 343.5, 344.0, 344.5, 345.0, 345.5, 346.0, 346.5, 347.0, 347.5, 348.0, 348.5,
          349.0, 349.5, 350.0, 350.5, 351.0, 351.5, 352.0, 352.5, 353.0, 353.5, 354.0, 354.5, 355.0, 355.5, 356.0,
          356.5, 357.0, 357.5, 358.0, 358.5, 359.0, 359.5, 360.0, 360.5, 361.0, 361.5, 362.0, 362.5, 363.0, 363.5,
          364.0, 364.5, 365.0, 365.5, 366.0, 366.5, 367.0, 367.5, 368.0, 368.5, 369.0, 369.5, 370.0, 370.5, 371.0,
          371.5, 372.0, 372.5, 373.0, 373.5, 374.0, 374.5, 375.0, 375.5, 376.0, 376.5, 377.0, 377.5, 378.0, 378.5,
          379.0, 379.5, 380.0, 380.5, 381.0, 381.5, 382.0, 382.5, 383.0, 383.5, 384.0, 384.5, 385.0, 385.5, 386.0,
          386.5, 387.0, 387.5, 388.0, 388.5, 389.0, 389.5, 390.0, 390.5, 391.0, 391.5, 392.0, 392.5, 393.0, 393.5,
          394.0, 394.5, 395.0, 395.5, 396.0, 396.5, 397.0, 397.5, 398.0, 398.5, 399.0, 399.5, 400.0, 400.5, 401.0,
          401.5, 402.0, 402.5, 403.0, 403.5, 404.0, 404.5, 405.0, 405.5, 406.0, 406.5, 407.0, 407.5, 408.0, 408.5,
          409.0, 409.5, 410.0, 410.5, 411.0, 411.5, 412.0, 412.5, 413.0, 413.5, 414.0, 414.5, 415.0, 415.5, 416.0,
          416.5, 417.0, 417.5, 418.0, 418.5, 419.0, 419.5, 420.0, 420.5, 421.0, 421.5, 422.0, 422.5, 423.0, 423.5,
          424.0, 424.5, 425.0, 425.5, 426.0, 426.5, 427.0, 427.5, 428.0, 428.5, 429.0, 429.5, 430.0, 430.5, 431.0,
          431.5, 432.0, 432.5, 433.0, 433.5, 434.0, 434.5, 435.0, 435.5, 436.0, 436.5, 437.0, 437.5, 438.0, 438.5,
          439.0, 439.5, 440.0, 440.5, 441.0, 441.5, 442.0, 442.5, 443.0, 443.5, 444.0, 444.5, 445.0, 445.5, 446.0,
          446.5, 447.0, 447.5, 448.0, 448.5, 449.0, 449.5, 450.0, 450.5, 451.0, 451.5, 452.0, 452.5, 453.0, 453.5,
          454.0, 454.5, 455.0, 455.5, 456.0, 456.5, 457.0, 457.5, 458.0, 458.5, 459.0, 459.5, 460.0, 460.5, 461.0,
          461.5, 462.0, 462.5, 463.0, 463.5, 464.0, 464.5, 465.0, 465.5, 466.0, 466.5, 467.0, 467.5, 468.0, 468.5,
          469.0, 469.5, 470.0, 470.5, 471.0, 471.5, 472.0, 472.5, 473.0, 473.5, 474.0, 474.5, 475.0, 475.5, 476.0,
          476.5, 477.0, 477.5, 478.0, 478.5, 479.0, 479.5, 480.0, 480.5, 481.0, 481.5, 482.0, 482.5, 483.0, 483.5,
          484.0, 484.5, 485.0, 485.5, 486.0, 486.5, 487.0, 487.5, 488.0, 488.5, 489.0, 489.5, 490.0, 490.5, 491.0,
          491.5, 492.0, 492.5, 493.0, 493.5, 494.0, 494.5, 495.0, 495.5, 496.0, 496.5, 497.0, 497.5, 498.0, 498.5,
          499.0, 499.5, 500.0, 500.5]
for i in range(n - (k - 1)):
    wk = 0
    for j in range(i, i + k):
        wk += p[j]
    if max < wk:
        max = wk
        for j in range(i, i + k):
            list[j - i] = p[j]
ans = 0
for i in range(k):
    ans += evlist[list[i] - 1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
*P, = map(int, input().split())
S   = [0]*(N+1)


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

right = 0
left  = 0
ans   = 0
for i in range(N-K+1):

    if ans <= (S[i+K]-S[i]):
        ans = (S[i+K]-S[i])
        right = i+K
        left  = i

ans = 0
for j in range(left, right, 1):
    ans = ans + sum(list(range(1,P[j]+1,1)))/(P[j])
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def get_e(p):
    return p*(p+1)/2/p

e_list = [get_e(p[i]) for i in range(N)]
c_e_list = [sum(e_list[i:i+K]) for i in range(N-K+1)]
print(max(c_e_list))

Submission status: Time Limit Exceeded

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

e_max = 0

def get_e(p):
    return p*(p+1)/2/p

for i in range(N-K+1):
    e = sum(map(get_e, p[i:i+K]))
    if e > e_max:
        e_max = e

print(e_max)

Submission status: Time Limit Exceeded

Solution code:

n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p = map(lambda x: sum(range(1,x+1))/x, p)

l = [0]
for i,v in enumerate(p):
    prev = l.pop()
    l.append(prev)
    l.append(prev + v)

ans = 0
for i in range(k, len(l)):
    tmp = l[i] - l[i-k]
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k = map(int, stdin.readline().rstrip().split())
p = list(map(int, stdin.readline().rstrip().split()))

m = 0
l =[]

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

ans = 0

for i in l:
    ans += (i+1) / 2

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

V = [0] * (N + 1)

for i in range(N):
    V[i + 1] = V[i] + sum(range(1, P[i] + 1)) / P[i]

# print(V)

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

print(res)