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


dice_ind = 0
temp = 0
for i in range(N-K+1):
    dice = sum(p[i:i+K])
    if dice > temp:
        dice_ind = i
        temp = dice
ans = 0
for i in p[dice_ind:dice_ind+K]:
    ans += (1+i)/2

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=[int(s) for s in input().split()]
b=[0]*k
c=0
for i in range(n-k+1):
    if sum(a[i:i+k])>=c:
        c=sum(a[i:i+k])
        for j in range(k):
            b[j]=a[i+j]
su=0
for i in range(k):
    su+=(b[i]+1)/2
print(su)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

def ev(n):
    return 0.5*(n+1)


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

    ans = []
    for i in range(n - k + 1):
        ans.append(sum(map(ev, p[i: i + k])))
    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def ev(n):
    return 0.5*(n+1)


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

    ans = []
    for i in range(n - k + 1):
        ans.append(sum(map(ev, p[i: i + k])))
    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

l = p[0:k]
l_sum = [sum(l)]
for i in range(k, n):
    l.pop(0)
    l.append(p[i])
    l_sum.append(sum(l))
ans = (max(l_sum)+k)/2
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 range(n - k + 1):
    l.append(sum(p[i:i + k]))
ans = (max(l)+k)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

p = input().split()
p = [int(i) for i in p]
p = np.array(p)
p = (p + 1) / 2

max = 0

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

print('{:.09f}'.format(max))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K=map(int,input().split())
a = np.array([int(x) for x in input().split()])
v = np.array([1]*K)
print(max(np.convolve(a, v, mode='valid'))/2+0.5*K)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print((K+M)/2)

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):
    l.append((1+p[i])/2)

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k))

Submission status: Time Limit Exceeded

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

ret = []
for i in range(1,max(p)+1):
    ret.append(i)

l = []
for i in range(N):
    l.append(sum(ret[0:p[i]])/p[i])

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k))

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):
    l.append(((1/2)*p[i]*(p[i]+1))/p[i])

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k))

Submission status: Time Limit Exceeded

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

l = []
a = 0
for i in range(N):
    for j in range(1,p[i]+1):
        a += j
    l.append(a/p[i])
    a = 0

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k))

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):
  ans=max(ans,sum(a[i:i+k]))
  
ans+=k
ans/=2

print(ans)

Submission status: Time Limit Exceeded

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

q=[]

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

ans=0

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

Submission status: Time Limit Exceeded

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

#logging.debug("デバッグスタート") #
l = [[] for i in range(n)]#期待値
m = [[] for i in range(n - k + 1)]  #k個の合計

for i in range(n):
    for j in range(p[i]):
        j += 1
        l[i].append(j/ p[i])
#        logging.debug("l[i]={},i={},j={}".format(l[i],i,j))
    l[i] = sum(l[i])

#logging.debug("l = {}".format(l))#
m[0] = sum(l[0:k])
ans = m[0]

for i in range(1, n - k + 1):
    #logging.debug("m[i-1] = {} ,l[i-1] = {} ,l[i+k] = {}".format(m[i - 1], l[i - 1], l[i + k - 1]))  #
    m[i] = m[i - 1] - l[i - 1] + l[i + k - 1]
    if m[i] > ans:
        ans = m[i]

#logging.debug(m)#
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 range(n)]#期待値
m = [[] for i in range(n - k + 1)]  #k個の合計

for i in range(n):
    for j in range(p[i]):
        j += 1
        l[i].append(j/ p[i])
#        logging.debug("l[i]={},i={},j={}".format(l[i],i,j))
    l[i] = sum(l[i])

#logging.debug("l = {}".format(l))#
m[0] = sum(l[0:k])

for i in range(1, n - k + 1):
    #logging.debug("m[i-1] = {} ,l[i-1] = {} ,l[i+k] = {}".format(m[i - 1], l[i - 1], l[i + k - 1]))  #
    m[i] = m[i - 1] - l[i - 1] + l[i + k - 1]

#logging.debug(m)#
print(max(m))

Submission status: Time Limit Exceeded

Solution code:
nn, kk = list(map(int,input().split()))
pp = list(map(int,input().split()))

expectation = [0]*(nn-kk+1)

for i in range(nn-kk+1):
    for j in range(kk):
        expectation[i] += pp[i+j]

print((max(expectation)+kk)/2)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    ans = 0
    for i in range(N-K+1):
        expected_sum = 0
        for j in range(i, i+K):
            expected_sum += (P[j]+1) / 2.0
        ans = max(expected_sum, ans)
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    ans = 0
    for i in range(N-K+1):
        target = P[i:i+K]
        expected_sum = sum([(num+1)/2.0 for num in target])
        ans = max(expected_sum, ans)
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
def main():
    """"ここに今までのコード"""
    N, K = map(int, input().split())
    dice_list = list(map(int, input().split()))
    expected_values = [sum(range(1, i + 1)) / i for i in dice_list]
    acc = [0 for i in range(N+1)]
    for i in range(1, N+1):
        n = dice_list[i-1]
        acc[i] = acc[i-1] + sum(range(1, n + 1)) / n 
    
    max_sum = -1

    for i in range(N - K + 1):
        s = acc[i + K] - acc[i]
        if s > max_sum:
            max_sum = s
    
    print(max_sum)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    """"ここに今までのコード"""
    N, K = map(int, input().split())
    dice_list = list(map(int, input().split()))
    expected_values = [sum(range(1, i + 1)) / i for i in dice_list]
    acc = [0 for i in range(N+1)]
    for i in range(1, N+1):
        acc[i] = acc[i-1] + expected_values[i-1]
    
    max_sum = -1

    for i in range(N - K + 1):
        s = acc[i + K] - acc[i]
        if s > max_sum:
            max_sum = s
    
    print(max_sum)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    """"ここに今までのコード"""
    N, K = map(int, input().split())
    dice_list = list(map(int, input().split()))
    expected_values = [sum(range(1, i + 1)) / i for i in dice_list]
    max_sum = -1

    for i in range(N - K + 1):
        s = sum([n for n in expected_values[i:i+K]])
        if s > max_sum:
            max_sum = s
    
    print(max_sum)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
P = inpl()

ave = []
for p in P:
    ave.append((p+1)/2)

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
X=[]
for a in P:
    X.append(a/2+0.5)

han=-32
for a in range(N-K+1):
    gou=0
    for b in range(K):
        i=a+b

        gou+=X[i]

    if gou>han:
        han=gou

print(han)

Submission status: Time Limit Exceeded

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

han=-32
for a in range(N-K+1):
    gou=0
    for b in range(K):
        i=a+b
        kei=sum(range(1,P[i]+1))/P[i]

        gou+=kei
    if gou>han:
        han=gou
print(han)

Submission status: Time Limit Exceeded

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

probs = []
for p in P:
    prob = 0
    for i in range(1,p+1):
        prob += i * (1/p)
    probs.append(prob)

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

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

max_i = -1
max_sum = -1
for i in range(N-K+1):
    csum = sum(p[i:i+K])
    if  csum > max_sum:
        max_sum = csum
        max_i = i

# print(max_sum)
# print(max_i)
ans = 0
for k in range(K):
    ans += (p[max_i+k]+1)/2

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print((s+k)/2)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,k = [int(x) for x in stdin.readline().rstrip().split()]
p = [(int(x)+1)/2 for x in stdin.readline().rstrip().split()]

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

print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
p = list(map(lambda x: (int(x)+1)/2, input().split()))

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

Submission status: Time Limit Exceeded

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

c = [None]*(n-k+1)
t = [0]*(n-k+1)
ttl = 0
for i in range(0, n-k+1):
    c[i] = p[i:k+i]
    cs = sum(c[i])
    if ttl < cs:
        ttl = cs
        t[i] = i
ans = 0
for j in c[max(t)]:
    ans += (j*(j+1)/2)/j

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n, k, *p = map(int, open(0).read().split())
ans = float()
for i in range(n - k + 1):
    ans = max(ans, (sum(p[i:k + i]) + k) / 2)
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):
  t = (sum(p[i:i+k])+k)/2
  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()))

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:
n,k = map(int,input().split())
p = list(map(int,input().split()))
walist=[]

for i in range(0,n-k+1):
    wa = 0
    for j in range(k):
        wa += p[i+j]
    walist += [wa]
print(max(walist)/2 + k/2)

Submission status: Time Limit Exceeded

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


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, k = MI()
    p = LI()
    max_seq = 0

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

    print((max_seq + k) / 2)


main()

Submission status: Time Limit Exceeded

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
p = l()

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

print(ans/2)

Submission status: Time Limit Exceeded

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
p = l()

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

aa = 0
for j in cnt:
    aa += (j+1)/2

print(aa)

Submission status: Time Limit Exceeded

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k=I()
p = l()

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

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

print(ans)

Submission status: Time Limit Exceeded

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

sum_p = 0

for i in range(n):
  if sum(p[i:i+k]) > sum_p:
    sum_p = sum(p[i:i+k])

print((sum_p + k)/2)

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

Submission status: Time Limit Exceeded

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


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, k = input_list()
    a = input_list()
    sums = 0
    max_kukan = []
    for i in range(n-k+1):
        kukan = a[i:i+k]
        if sum(kukan) > sums:
            sums = sum(kukan)
            max_kukan = kukan
    ans = list(map(lambda x: (x+1)/2, max_kukan))
    print(sum(ans))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, k = input_list()
    a = input_list()
    ans = 0
    for i in range(n-k+1):
        kitai = list(map(lambda x: (x+1)/2, a[i:i+k]))
        ans = max(ans, sum(kitai))
    print(ans)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

mmax = 0
idx = 0
for i in range(N-K+1):
  score = sum(P[i:i+K])
  if score > mmax:
    mmax = score
    idx = i
  else:
    continue

print((K+mmax)/2)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
P = list(map(int, input().split()))

S = []

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

ans = sum(S)

for i in range(K,N):
    S.append((P[i]+1)/2)
    ans = max(ans, sum(S[i-K+1:]))


print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
P = list(map(int, input().split()))


S = []

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

ans = sum(S)

for i in range(K,N):
    S.pop(0)
    S.append((P[i]+1)/2)
    ans = max(ans, sum(S))


print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
P = list(map(int, input().split()))

# 1+0.5(N-1)

print()

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

ans = 0
for j in range(start,start+K):
    ans += (P[j]+1)/2

print(ans)

Submission status: Time Limit Exceeded

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


def calc(n):
    ans = 0
    for i in range(1, n+1):
        ans += i/n
    return ans


for i in range(maxI-k+1, maxI+1):
    #print(i, p[i])
    ans += calc(p[i])
# print(p)
#print(maxT, maxI)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

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

pn1 = p - 1

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int, input().split())
c=list(map(int, input().split()))
l =[]
ans = 0

def abc(n):
    return (n+1)/2

cb = list(map(abc,c))

for i in range(a-b+1):
    for k in range(b):
        ans += cb[i+k]
    l.append(ans)
    ans = 0

L = sorted(l)
print(L[-1])

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int, input().split())
c=list(map(int, input().split()))
l =[]
ans = 0

for i in range(a-b+1):
    for k in range(b):
        ans += (c[i+k]+1)/2
    l.append(ans)
    ans = 0

L = sorted(l)
print(L[-1])

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(sum(P[i:i + K]), ans)
print((ans + K) / 2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    # Pk_max_idx = numpy.argmax(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))
    # Pk_max_idx = (numpy.max(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))+1)*(K/2)
    # print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)
    print((numpy.max(scipy.convolve(P,numpy.ones(K,dtype='float'), mode='valid')/scipy.convolve(numpy.ones(len(P)),numpy.ones(K),mode='valid'))+1)*(K/2))
    # print((numpy.max(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))+1)*(K/2))
main()

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    # Pk_max_idx = numpy.argmax(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))
    # Pk_max_idx = (numpy.max(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))+1)*(K/2)
    # print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)
    print((numpy.max(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))+1)*(K/2))

main()

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pk_max_idx = numpy.argmax(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))
    print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)

main()

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pk_max_idx = numpy.argmax([sum(P[i:i+K]) for i in range(len(P))])
    print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)

main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

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())))
Q=P.copy()

for _ in range(K-1):
  P=P[1:]
  Q=Q[:-1]
  P=P+Q
  
print((max(P)+K)/2)

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):
  try:
    ans=max(ans,sum(P[i:i+K]))
  except:
    break
print((ans+K)/2)

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())))
 
ans=0
for i in range(N):
  try:
    ans=max(ans,sum(P[i:i+K]))
  except:
    break
print((ans+K)/2)

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())))
 
P=(P+1)/2
ans=0
for i in range(N):
  try:
    ans=max(ans,sum(P[i:i+K]))
  except:
    break
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 range(n):
  l.append(sum(p[i:i+k]))

ans=0.0
max=l.index(max(l))
ans=sum(list(range(1,p[max]+1)))/p[max]
x=sum(list(range(1,p[max]+1)))/p[max]
p0=p[max]
for i in range(max+1,max+k):
  g=p[i]-p[max]
  #print(p[max],p[i])
  ans+=x+(g*0.5)
  
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 range(n):
  l.append(sum(p[i:i+k]))

ans=0.0
max=l.index(max(l))
for i in range(k):
  ans+=sum(list(range(1,p[max+i]+1)))/p[max+i]
  
print(ans)

Submission status: Time Limit Exceeded

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

max=p[0:k]
for i in range(n):
  if sum(p[i:i+k]) >= sum(max):
    max=p[i:i+k]

ans=0.0
#print(max,k)
for i in max:
  x=float(1/i)
  for j in range(1,i+1):
    ans+=float(j*x)
print(ans)