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

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

expect=[(dice+1)/2 for dice in p]
for i in range(N-1):
    expect[i+1]+=expect[i]

plus_p=[expect[K-1]]
for i in range(1, N-K+1):
    plus_p.append(expect[i+K-1]-expect[i-1])
print(max(plus_p))

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

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



first=sum(expect[0:K])
plus_p=[first]
for i in range(1, N-K+1):
	plus_p.append(plus_p[i-1]-expect[i-1]+expect[i-1+K])

print(max(plus_p))

Solution (Python):
import queue

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

A_expect=[a+1 for a in A]
q = queue.Queue()
S=0
ans=0
for a_e in A_expect:
    S+=a_e
    q.put(a_e)
    if q.qsize()>K:
        S-=q.get()
    if q.qsize()==K:
       ans=max(ans,S)
ans/=2
print(ans)

Solution (Python):
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
print(max_wa)

Solution (Python):

N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))


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


S = [0] * (N +1)



for i in range(1,N +1):
    S[i] = S[i-1] + kitaiti[i-1]


S_K = []
for i,v in enumerate(S[:(-1)*K ]):
    S_K.append( S[i + K ] - S[i] )
"""
print(kitaiti)
print(S)
print(S_K)
"""
print(max(S_K))

Solution (Python):
class BIT:
    def __init__(self, n):
        self.node = [ 0 for _ in range(n+1) ]

    def add(self, idx, w):
        i = idx
        while i < len(self.node) - 1:
            self.node[i] += w
            i |= (i + 1)

    def sum_(self, idx):
        ret, i = 0, idx-1
        while i >= 0:
            ret += self.node[i]
            i = (i & (i + 1)) - 1
        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


n, k = map(int, input().split())
tree = BIT(n)
p = [ int(x) for x in input().split() ]

for i in range(n):
    tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, tree.sum(i, i+k))

print(ans)

Solution (Python):
import numpy as np
N, K = map(int, input().split())
a = np.array(list(map(int, input().split())))
a = (a + 1) / 2
total = 0
maxi = 0
for i in range(0, N):
    total += a[i]
    if i >= K - 1:
        maxi = max(maxi, total)
        total -= a[i-(K-1)]
print('{:.12f}'.format(maxi))

Solution (Python):
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 0
    E = [0] * N
    for i in range(N):
        E[i] = ((P[i] * (P[i] + 1)) // 2) / P[i]

    F = [0] + list(accumulate(E))
    ans = 0
    for i in range(N-K+1):
        tmp = F[i+K] - F[i]
        ans = max(ans, tmp)

    print(ans)






if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = deque([])
for i, x in enumerate(p):
    if i == 0:
        p_acc.append((x + 1) / 2)
    else:
        p_acc.append((x + 1) / 2 + p_acc[i - 1])
ans = 0
for i in range(n - k + 1):
    equity = p_acc[k - 1 + i] - p_acc[i - 1] if i != 0 else p_acc[k - 1]
    if equity > ans:
        ans = equity
print(ans)

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

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

e = sum(E[:K])
ans = e
for i in range(1, N-K+1):
  e = e - E[i-1] + E[i+K-1]
  if ans < e:
    ans = e
    
print(ans)

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


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



cusum = [0]
for e in E:
    cusum.append(cusum[-1] + e)



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

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
x=sum(p[:k])
max_x=x
idx=0
for i in range(k,n):
  x=x+p[i]-p[i-k]
  if max_x<x:
    idx=i-k+1
    max_x=x
ans=0
for i in range(idx,idx+k):
  ans+=(p[i]*(p[i]+1)//2)/p[i]
print(ans)

Solution (Python):
class SegmentTree:
    seg_len = 1
    node = []
    def __init__(self, n):
        while self.seg_len < n:
            self.seg_len <<= 1
        self.node = [ 0 for _ in range(self.seg_len*2) ]

    def add(self, idx, v):
        idx += self.seg_len
        self.node[idx] += v
        while True:
            idx >>= 1
            if idx == 0:
                break
            self.node[idx] = self.node[idx*2] + self.node[idx*2+1]

    def sum(self, l, r):
        l += self.seg_len
        r += self.seg_len
        ret = 0
        while l < r:
            if l & 1 == 1:
                ret += self.node[l]
                l += 1
            if r & 1 == 1:
                ret += self.node[r-1]
                r -= 1
            l >>= 1; r >>= 1;
        return ret


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

seg_tree = SegmentTree(n)
for i in range(n):
    seg_tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, seg_tree.sum(i, i+k))

print(ans)

Solution (Python):
class SegmentTree:
    seg_len = 1
    node = []
    def __init__(self, n):
        while self.seg_len < n:
            self.seg_len <<= 1
        self.node = [ 0 for _ in range(self.seg_len*2) ]

    def add(self, idx, v):
        idx += self.seg_len
        self.node[idx] += v
        while True:
            idx //= 2
            if idx == 0:
                break
            self.node[idx] = self.node[idx*2] + self.node[idx*2+1]

    def sum(self, l, r):
        l += self.seg_len
        r += self.seg_len
        ret = 0
        while l < r:
            if l & 1 == 1:
                ret += self.node[l]
                l += 1
            if r & 1 == 1:
                ret += self.node[r-1]
                r -= 1
            l //= 2; r //= 2;
        return ret


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

seg_tree = SegmentTree(n)
for i in range(n):
    seg_tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, seg_tree.sum(i, i+k))

print(ans)

Solution (Python):
n,k=map(int,input().split())
P=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n):
    dp[i+1]=dp[i]+P[i]
ma=0
for i in range(n-k+1):
    ma=max(ma,dp[i+k]-dp[i])
print((ma+k)/2)

Solution (Python):
x,y=list(map(int, input().split()))
z=list(map(int, input().split()))
ans=0
chk=0
for i in range(y):
	ans=ans+z[i]
	chk=ans
for i in range(x-y):
	chk=chk-z[i]+z[i+y]
	if chk>ans:
		ans=chk
print((ans+y)/2)

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

Solution (Python):
class BIT:
    def __init__(self, n):
        self.bit = [ 0 for _ in range(n+1) ]

    def add(self, x, w):
        i = x
        while i < len(self.bit)-1:
            self.bit[i] += w
            i |= (i+1)

    def sum_(self, x):
        ret, i = 0, x-1
        while i >= 0:
            ret += self.bit[i]
            i = (i & (i+1)) - 1

        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


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

tree = BIT(n)
for i in range(n):
    tree.add(i, (p[i] + 1) / 2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, tree.sum(i, i+k))

print(ans)

Solution (Python):
class BIT:
    def __init__(self, n):
        self.bit = [ 0 for _ in range(n+1) ]

    def add(self, x, w):
        i = x
        while i < len(self.bit)-1:
            self.bit[i] += w
            i |= (i+1)

    def sum_(self, x):
        ret, i = 0, x-1
        while i >= 0:
            ret += self.bit[i]
            i = (i & (i+1)) - 1

        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


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

tree = BIT(n)
for i in range(n):
    tree.add(i, (p[i] + 1) / 2)

ans = 0
for i in range(n-k+1):
    ans = max(ans, tree.sum(i, i+k))

print(ans)

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

e = []
max_ = 0
sum_ = 0
f = []
e = [(1+p[i])/2  for i in range(n)]
for i in range(n):
    if i < k:
        sum_ += e[i]
        max_ = sum_
    else:
        sum_ = sum_ + e[i] - e[i - k]
        max_ = max(max_, sum_)

print(max_)

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

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

Solution (Python):
n,k = map(int,input().split(" "))
c = list(map(int,input().split(" ")))
ans = 0
kar = 0
for i in range(n):
    c[i] = (c[i]+1)/2

for i in range(n):
    if i + 1 <= k:
        ans += c[i]
        kar += c[i]
    else:
        kar += c[i] - c[i-k]
        if ans <= kar:
            ans = kar
print(ans)

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

Solution (Python):
import copy
import math
import string

N,K = map(int,input().split())
p = list(map(int,input().split()))
k = [0]*N
s = [0]*(N+1)
for i in range(N):
    k[i] = (1+p[i])/2
    s[i+1] = s[i]+k[i]

ans = 0
for i in range(N+1):
    if i - K < 0:
        continue
    ans = max(ans,s[i]-s[i-K])
print(ans)

Solution (Python):
N,K = (int(x) for x in input().split())
max_e = 0.0
e = 0.0
cnt = 0
p = list(map(float,input().split()))
for i in range(N):
  n = p[i]
  p[i] = n*(n+1)/(2.0*n)
  
for i in range(N):
  cnt += 1
  e += p[i]
  if cnt == K:
    n = p[i-K+1]
    if max_e < e:
      max_e = e
    cnt = K-1
    e -= n

print(max_e)

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

p=list(map(int,input().split()))
l=[0]*k
ans=0
for i in range(k):
    aa=1+0.5*(p[i]-1)
    ans+=aa
th=ans
for j in range(k,n):
    a=1+0.5*(p[j-k]-1)
    b=1+0.5*(p[j]-1)

    if ans-a+b>th:
        th=ans-a+b
    ans=ans-a+b

print(th)
"""
1=>1
2=>1.5
3=>2
4=>2.5
5=>3
6=>3.5
7=>4
8=>4.5
9=>5
10=>5.5
11=>6

1+0.5*(n-1)

1+0.5*10"""

Solution (Python):
N, K = map(int, input().split())
lst = [0]
for x in [int(x) for x in input().split()]:
    lst.append(lst[-1] + ((1 + x) / 2))

ret = 0
for i in range(N - K + 1):
    ret = max(ret, lst[i + K] - lst[i])
print(ret)

Solution (Python):












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

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

sumlist = [0]
meansum = 0
for num in arrP:
    heikin = (1 + num)/2
    meansum += heikin
    sumlist.append(meansum)

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

print(ans)

Solution (Python):
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)

Solution (Python):

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

Solution (Python):
N, K = map(int, input().split())
P = [int(i) for i in input().split()]
ex_list = []
ex = 0
sum = 0
for j in range(K):
  sum += P[j]
ex_list.append((sum + K) / 2)
for i in range(N - K):
  sum = sum - P[i] + P[i + K]
  ex_list.append((sum + K) / 2)
print(max(ex_list))

Solution (Python):

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=sum(p[:k])
res=c
for i in range(n-k):
 c=c-p[i]+p[i+k]
 res=max(res,c)
print((res+k)/2)

Solution (Python):
import numpy
N, K = map(int, input().split())
P = [int(i) for i in input().split()]
P = [0]+list(map(lambda x: (x+1)/2, P))

S = numpy.cumsum(P)

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

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
for i in range(k):
    cur += (a[i]+1)/2
maximum = cur

for i in range(1, n-k+1):
    cur -= (a[i-1]+1)/2
    cur += (a[i+k-1]+1)/2
    maximum = max(maximum, cur)

print(maximum)

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

e = [0] * 1001
e[1] = 1.0
for i in range(2, 1001):
    e[i] = e[i-1] + 0.5

ans = [0] * (n-k+1)
for i in range(k):
    ans[0] += e[p[i]]
for i, v in enumerate(range(k, n), start=1):
    ans[i] = ans[i-1] + e[p[v]] - e[p[v-k]]
print(max(ans))

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


def est(i):
    return 1.0 + (i - 1) * 0.5






























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




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

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

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


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

Solution (Python):
n, k = map(int, input().split())
pp = list(map(int, input().split()))

answer = sum(pp[:k])
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
mx=sm=sum(P[:K])
for i in range(N-K):
    sm=sm+P[i+K]-P[i]
    mx=max(mx,sm)
print((mx+K)/2)

Solution (Python):

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

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

print((ans + k) / 2)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = 0.0
for i in range(k):
    tmp += (p[i]+1)/2
ans = tmp
for i in range(k, n):
    tmp += (p[i]-p[i-k])/2
    if ans < tmp:
        ans = tmp

print(ans)

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


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

Pmean=list(map(lambda x: n_mean(x), P))
Psum=[0]*N
Psum[0]=Pmean[0]
for i in range(1,N):
  Psum[i]=Psum[i-1]+Pmean[i]

ans=0
for i in range(N-K+1):
  if i==0:
    ans=Psum[K-1]
  else:
    
    ans=max(ans, (Psum[i+K-1]-Psum[i-1]))
  
print(ans)

Solution (Python):

from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int,input().split()))

m = [(e + 1) / 2 for e in p]
    
m = [0] + m
m = list(accumulate(m))

ans = []
for i in range(n-k+1):
    ans.append(m[i+k] - m[i])
    
print(max(ans))

Solution (Python):
nk=input().rstrip().split(" ")
n=int(nk[0])
k=int(nk[1])
numbers=input().rstrip().split(" ")
sigmas=[0]
sigma=0
for i in range(n):
    sigma=sigma+(int(numbers[i])+1)/2
    sigmas.append(sigma)

deltas=[]
for i in range(n-k+1):
    delta=sigmas[k+i]-sigmas[i]
    deltas.append(delta)

answer=0
for delt in deltas:
    if delt>=answer:
        answer=delt
print(answer)

Solution (Python):


def submit():
    n, k = map(int, input().split())
    plist = list(map(int, input().split()))
    
    
    exp = {1: 1}
    max_p = max(plist)
    for x in range(2, max_p + 1):
        exp[x] = exp[x - 1] + x
    for x in range(1, max_p + 1):
        exp[x] /= x
    
    
    explist = [exp[p] for p in plist]
    curr_sum = sum([e for e in explist[:k]])
    curr_max = curr_sum

    l, r = 1, k
    while r < n:
        curr_sum += explist[r] - explist[l - 1]
        if curr_sum > curr_max:
            curr_max = curr_sum
        l += 1
        r += 1

    print(curr_max)
    

if __name__ == "__main__":
    submit()

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

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

sum_ = sum(kobetu_kitaiti[0:K])
max_ = sum_

for i in range(N-K):
    sum_ = sum_ - kobetu_kitaiti[i] + kobetu_kitaiti[i+K]
    max_ = max(sum_, max_)


print(max_)

Solution (Python):
from itertools import accumulate    

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

    compute_list = []

    for num in num_list:
        compute_list.append((1+num)/2)

    sum_list = list(accumulate(compute_list))

    if k == n:
        print(sum_list[k-1])
        exit()

    ans = 0

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

    print(ans)

if __name__ == '__main__':
    main()

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

s = []
sum = 0
for i in range(k):
    sum += p[i]

s.append(sum)

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

m = max(s)/2 + k/2

print(m)

Solution (Python):

def sum_ari_seq(a):
    return a * (a + 1) // 2


def mean(a):
    return sum_ari_seq(a) / a


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

max_value = 0
for i in range(k):
    max_value += mean(p[i])

cur = max_value
for i in range(k, n):
    cur += (mean(p[i]) - mean(p[i-k]))
    max_value = max(max_value, cur)

print(max_value)

Solution (Python):
import sys

input = sys.stdin.readline

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

q = []

for value in p:
    q.append((value + 1) / 2)

sm = [sum(q[:K])]
for i in range(1, N-K+1):
    sm.append(sm[-1] - q[i-1] + q[i+K-1])

print(max(sm))

Solution (Python):
def __main():
    n,k = map(int, input().split())
    P = list(map(int, input().split()))
    P = list(map(lambda x:(x+1)/2, P))

    cur = sum(P[:k])
    
    ans = cur

    for i in range(1, n-k+1):
        cur += P[i+k-1] - P[i-1]
        if cur < ans: continue
        ans = cur

    print(ans)
__main()

Solution (Python):
import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [0] + p
m = (np.array(p) + 1)/2
m[0] = 0
cum  = np.cumsum(m)

ma = 0
for i in range(n - k + 1):
    a = cum[i + k] - cum[i]
    if ma < a:
        ma = a
print(ma)

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
l2 = [0 for _ in range(n+1)]
for i in range(n):
  l[i] = 1+l[i]
for i in range(n):
  l2[i + 1] = l2[i]+l[i]
l3 = []
for i in range(n-k+1):
  l3.append(l2[i+k]-l2[i])
print("{:.8}".format(max(l3)/2))

Solution (Python):
from math import fsum
s = [0] * 1001
for i in range(1, len(s)):
    s[i] = s[i - 1] + i
N, K = map(int, input().split())
exps = [s[p] / p for p in map(int, input().split())]
exp = fsum(exps[:K])
ans = exp
for i in range(K, N):
    exp = fsum((exp, -exps[i - K], exps[i]))
    if ans < exp:
        ans = exp
print(ans)

Solution (Python):
n,k=map(int,input().split())
s=list(map(int,input().split()))

ans=0
tmp=0
tmp2=sum(s[0:k])
kukan=[0,n]
for i in range(n-k):
    tmp2 -= s[i]
    tmp2 += s[k+i]
    if tmp < tmp2:
        tmp = tmp2
        kukan = [i+1,i+k+1]

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)

Solution (Python):
n, k = map(int, input().split(' '))
pp = list(map(int, input().split(' ')))

pp_ex = list(map(lambda p: (p + 1) / 2, pp))

max_ex = 0
for i in range(k):
    max_ex += pp_ex[i]
bef_ex = max_ex
for i in range(1, n - k + 1):
    ex = bef_ex - pp_ex[i - 1] + pp_ex[i + k - 1]
    bef_ex = ex
    if max_ex < ex:
        max_ex = ex

print(max_ex)

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    p2 = [(i + 1) / 2 for i in p]
    l = []
    for i in range(N - (K - 1)):
        if i == 0:
            s = 0
            for j in range(K):
                s += p2[j]
            l.append(s)
        else:
            l.append(l[-1] - p2[i - 1] + p2[i + (K - 1)])
    print(max(l))
    
    
    
    
    
    
    



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, p)

if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)

Solution (Python):
def main():
    
    n,k = map(int, input().split())
    
    p_list = list(map(int, input().split()))
 
    
    
 
    ans = 0
    if k == 1:
        p_list.sort(reverse=True)
        ans = (p_list[0]+1)*0.5
    else:
        for j in range(n-(k-1)):
            if j == 0:
                ans_tmp = 0
                for i in range(k):
                    ans_tmp += (p_list[i+j]+1)*0.5
            else:
                ans_tmp -= (p_list[(j-1)]+1)*0.5
                ans_tmp += (p_list[k+(j-1)]+1)*0.5
            
            
            if ans_tmp >= ans:
                ans = ans_tmp
 
    print(ans)
 
    
 
if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, k = na()
p = na()
s = 0
for i in range(k):
    s += 1/p[i] * (1/2) * (1 + p[i]) * p[i]
ans = s
l = 0
r = k
for i in range(n-k):
    
    s -= 1/p[l] * (1/2) * (1 + p[l]) * p[l]
    s += 1/p[r] * (1/2) * (1 + p[r]) * p[r]
    ans = max(ans, s)
    l += 1
    r += 1
print(ans)

Solution (Python):
M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
Q.append(S[K-1])
q=0
for i in range(N-K):
    q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))

Solution (Python):
N,K=map(int,input().split())
p=input().split()
P=[int(z) for z in p]
hopes=[(1+a)/2 for a in P]
S=sum(hopes[:K])
answers=[S]
for a in range(1,N-K+1):
    S=S+hopes[a+K-1]-hopes[a-1]
    answers.append(S)
print(max(answers))

Solution (Python):
import time
start = time.time()

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

ans = 0






total = [0] * n
for i in range(n):
    if i == 0:
        total[i] = p[i]
    else:
        total[i] = total[i-1] + p[i]
maxi_sum = 0
maxi_num = 0
for i in range(k-1, n):
    if i == k-1:
        maxi_sum = total[i]
        maxi_num = i
    else:
        if total[i] - total[i-k] > maxi_sum:
            maxi_sum = total[i] - total[i-k]
            maxi_num = i

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
ans = 0
for pi in p:
    ev.append((pi + 1) / 2)
cs = [0]
for i in range(n):
    cs.append(cs[i] + ev[i])

for i in range(k, n+1):
    cost = cs[i] - cs[i-k]
    
    if ans < cost:
        ans = cost

print(ans)

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

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    

print(ans)

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

E = [0] * N

for i, p in enumerate(P):
  E[i] = (1 + p) * p / 2 / p
  

sum_exp = sum(E[0:K])
max_exp = sum_exp

for head, e in enumerate(E[K:], 0):
  sum_exp = sum_exp - E[head] + e
  max_exp = max(max_exp, sum_exp)
  
print(max_exp)

Solution (Python):


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

S = [0]

for i in range(N):
    S.append(S[i]+P[i])

ans = 0

for j in range(K, N+1):
    if S[j]-S[j-K]>ans:
        ans = S[j]-S[j-K]

print(0.5*(K+ans))

Solution (Python):


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

S = [0] * (N+1)

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

ans = 0

for j in range(K, N+1):
    if S[j]-S[j-K]>ans:
        ans = S[j]-S[j-K]

print(0.5*(K+ans))

Solution (Python):
from sys import stdin


N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]

D = sum(P[:K])
index = 0
ans = D

for i in range(1, N - K + 1):
    if D + P[i + K - 1] - P[i - 1] > ans:
        ans = D + P[i + K - 1] - P[i - 1]
    D = D + P[i + K - 1] - P[i - 1]
print((ans + K) / 2)

Solution (Python):
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [(int(x) + 1) / 2 for x in stdin.readline().rstrip().split()]

D = sum(P[:K])
index = 0
ans = D

for i in range(1, N - K + 1):
    if D + P[i + K - 1] - P[i - 1] > ans:
        ans = D + P[i + K - 1] - P[i - 1]
    D = D + P[i + K - 1] - P[i - 1]
print(ans)

Solution (Python):

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


exp_value_list = list()
for i in range(N):
    exp_value_list.append(((p_list[i])+1)/2)


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


selected = ans
for i in range(0,N-K):
    selected -= exp_value_list[i]
    selected += exp_value_list[i+K]
    ans = max(ans,selected)
    
print(ans)

Solution (Python):
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*(len(d)+1)


w[0] = 0
for i in range(0, len(d)):
  w[i+1] = w[i] + d[i]
  
ans = 0
for i in range(0, a-b+1):
    ans = max([ans,w[i+b]-w[i]])

d2 = 0.5*b + ans/2

if a == 1:
  print((d[0]+1)/2)
else:
  print(d2)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
ans=f
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
ans=f
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))

sum_tmp = sum(a[:k])
sum_max = sum_tmp
for i in range(k,len(a)):
    sum_tmp += a[i] - a[i-k]
    if sum_tmp > sum_max:
        sum_max = sum_tmp
print((sum_max + k)/2)

Solution (Python):
N, K = map(int, input().split())
p = list(map(lambda x: (int(x) + 1)/2, input().split()))

asum = [p[0]]
for i in range(1, N, 1):
	asum.append(asum[i - 1] + p[i])

tsum = [asum[K - 1]]
for i in range(K, N, 1):
	tsum.append(asum[i] - asum[i - K])

print(max(tsum))

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

p_e = [0] + [ (x + 1) * 0.5 for x in p]
p_p = [0]

for i in range(1, n+1):
    p_p.append(p_p[i-1] + p_e[i])

e_sum = [p_p[i] - p_p[i - k] for i in range(k, n+1)]
print(max(e_sum))

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

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

Solution (Python):
from sys import stdin
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
s = list(map(int, input().split()))
ans = [0]*N
sum
for i in range(0, K):
    ans[i] = (s[i]+1)/2
sum = sum(ans)
mx = sum
for i in range(K, N):
    ans[i] = (s[i]+1)/2
    sum = sum+ans[i]-ans[i-K]
    if mx < sum:
        mx = sum

print(mx)

Solution (Python):
N,K=map(int,input().split())
p=list(map(float,input().split()))
maxexp=float(0)


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


p=list(map(expected,p))

for i in range(K):
    maxexp+=p[i]
now=maxexp
for i in range(N-K):
    now=now+p[i+K]-p[i]
    maxexp=max(now,maxexp)
print(maxexp)

Solution (Python):
from decimal import Decimal

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

cur = sum(p[:k])
res = cur

for i in range(k, n):
    cur += p[i] - p[i-k]
    res = max(res, cur)

d = Decimal(res.numerator) / Decimal(2*res.denominator)
print(d)

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
s = 0
Max = 0
for i in range(N):
    s += (p[i]+1)/2
    S.append(s)
for i in range(N-K+1):
    s = S[i+K] - S[i]
    if s > Max:
        Max = s
print(Max)

Solution (Python):
all_num, select_num = map(int, input().split())
dice = [int(a) for a in input().split()]

for i in range(all_num - (select_num - 1)):
    if i == 0:
        max_sum = this_sum = sum(dice[i:(i + select_num)])
    else:
        this_sum = this_sum - dice[i - 1] + dice[i + select_num - 1]

        if this_sum > max_sum:
            max_sum = this_sum

print((max_sum + select_num) * 0.5)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
E = [(1+p[i])/2 for i in range(N)]
S = [0]
for i in range(0,N):
  S.append(S[i]+E[i])

maxnum = 0
for i in range(N+1):
  if i+K >= N+1:
    break
  maxnum = max(S[i+K]-S[i], maxnum)
print(maxnum)

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

Solution (Python):
N, M = map(int, input().split())
lst = list(map(int, input().split()))
lst2 = []
for i in lst:
  lst2.append((i*(i+1)//2)/i)
ans = sum(lst2[:M])
max_ans = ans
num = 0
for i in range(M, N):
  ans = ans - lst2[num] + lst2[i]
  num += 1
  if ans > max_ans:
    max_ans = ans
print(max_ans)

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