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 = list(map(int,input().split()))
p = list(map(int,input().split()))
sum_max = 0
sum_temp = sum(p[0:K])
k_temp = 0
for k in range(1,N-K+1):
	sum_temp -= p[k-1]
	sum_temp += p[k+K-1]
	if sum_temp > sum_max:
		sum_max = sum_temp
		k_temp = k
ans = 0

for j in range(k_temp,k_temp+K):
	ans += (p[j]+1)/2
print(ans)

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

cuml=[]
cum=0
for i in range(n):
    cum+=(pl[i]+1)/2
    cuml.append(cum)
mx=0
for i in range(n-(k-1)):
    if i==0:
        mx=max(cuml[i+k-1],mx)
    else:
        mx=max(cuml[i+k-1]-cuml[i-1],mx)
print('{:.9f}'.format(mx))

Solution (Python):
def exp(n):
  return n * (n + 1) / n / 2

N, K = map(int, input().split())
p = list(map(int, input().split()))
a = [0.0]
for i in range(N):
  a.append(a[i] + exp(p[i]))
m = 0
for i in range(N - K + 1):
  m = max(m, a[i + K] - a[i])
print(m)

Solution (Python):
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if K == 1:
    max_val = max(Ps)
    print((max_val + 1) / 2)
elif N == K:
    max_val = Ps_sum_list[-1]
    print((max_val + K) / 2)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Solution (Python):
def f(x):
    return (x + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[:k])
a = ans
for i in range(k, n):
    a = a + p[i] - p[i - k]
    ans = max(ans, a)
print(ans)

Solution (Python):


import numpy as np

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

b=np.concatenate([np.array([0]),np.cumsum(p)])

K_sum = b[K:] - b[:-K]
    
print((max(K_sum)+K)/2)

Solution (Python):


from itertools import accumulate

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

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)

Solution (Python):
import sys
input = sys.stdin.readline

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

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

Solution (Python):
import numpy as np
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = np.array(s)
ans =  np.sum(s[:k])
a = ans
for i in range(n-k):
  a = a - s[i] + s[i+k]
  if a > ans:
    ans = a  
print((ans+k)/2)

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


def expect(n):
    res = (n + 1) / 2
    return res

p = list(map(expect, p))
ans_sum = sum(p[:k])
tmp_sum = ans_sum
idx = 0

for i in range(k, n):
    tmp_sum = tmp_sum + p[i] - p[i-k]
    if tmp_sum > ans_sum:
        ans_sum = tmp_sum

print(ans_sum)

Solution (Python):
N, K = map(int,input().split())
list_p = [int(x) for x in input().split()]

total = sum(list_p[0:K])
max = total

for i in range(0,N-K) :
    total = total - list_p[i] + list_p[i+K]
    if total > max :
        max = total

print((max+K)/2)

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

Solution (Python):
def calc(x):
    return (x+1)/2

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

_ans = sum(p[0:k])
ans = _ans
for x in range(n-k):
    
    _ans = _ans - p[x] + p[x + k]
    ans = max(ans, _ans)

print(ans)

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

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

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


sum_E = [0, ]
for i in range(N):
    sum_E.append(sum_E[i] + E[i])


sum_K = []
ans = 0
for i in range(N-K+1):
    if sum_E[i+K] - sum_E[i] > ans:
        ans = sum_E[i+K] - sum_E[i]
print(ans)

Solution (Python):

import numpy as np

n,k = map(int, input().split())
p_list = np.fromstring(input(), int, sep=' ')

Cumulative_sum = np.zeros(n+1)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

print((length_k_sum_list.max()+k)/2)

Solution (Python):


import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(),int,sep=' ')

Cumulative_sum = np.zeros(n+1, int)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

print((length_k_sum_list.max()+k)/2)

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

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

m = check = sum(p[0:K])
for i in range(K,N):
  check = check+p[i]-p[i-K]
  m = max(m,check)
print(m)

Solution (Python):
n , k = map(int, input().split())
p = list(map(int, input().split()))
p_accu = [p[0] + 1]

if k == 1:
    print((max(p) + 1 ) / 2 )
    exit()
elif k == n:
    print((sum(p) + n ) / 2 )
    exit()

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

S = p_accu[k-1]

for i in range(n - k):
    if S < p_accu[i+k] - p_accu[i]:
        S = p_accu[i+k] - p_accu[i]
    
print(S/2)

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

P = list(accumulate([(i+1)/2 for i in p]))
P = [0] + P
ans = max([P[i+k]-P[i] for i in range(n-k+1)])
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = [(int(p) + 1) / 2. for p in input().split()]
sumexp = sum(p[:k])
maxexp = sumexp
for i in range(n-k):
  sumexp += p[i+k] - p[i]
  if sumexp > maxexp:
    maxexp = sumexp
print(maxexp)

Solution (Python):
import queue

nk = input()

po = input()

N = int(nk.split(' ')[0])
K = int(nk.split(' ')[1])

p = po.split(' ')
p2 = [(int(i) + 1 )/2 for i in p]


q = queue.Queue()
rui = [p2[0]]
for i in range(1,N):
    
    
    rui.append(rui[i-1] + p2[i])



tes = 0
maxv = 0
for i in range(K-1,N):
    
    tes = rui[i]
    if(i >= K):
        tes -= rui[i-K]
    
    if(maxv < tes):
        maxv = tes
print(maxv)

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


l=sum(P[0:K])
k=l
for i in range(N-K):
  l = l-P[i]+P[i+K]
  if l>k:
    k=l

print((k+K)/2)

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
now = sum(P[:K])
ans = now
for j in range(N-K):
  now = now - P[j] + P[j+K]
  ans = max(ans,now)
print(ans)

Solution (Python):
n, k = input().split()
n = int(n)
k = int(k)
p = list(map(int, input().split()))
if n==k:
	print((sum(p)+n)/2)
else:
	q = [p[0]]
	for i in range(n-1):
		q.append(q[i]+p[i+1])
	r = []
	for i in range(n-k):
		r.append(q[i+k]-q[i])
	r.sort(reverse=True)
	print((r[0]+k)/2)

Solution (Python):
n,k=map(int, input().split())
p=list(map(int, input().split()))
numset=[]
sexp=[]
tmp=0
ans=0
for i in range(max(p)+1):
  tmp=tmp+i
  numset.append(tmp)
exp=[]
for i in p:
  exp.append(numset[i]/i)
sexp.append(0)
s=0
for i in exp:
  s=s+i
  sexp.append(s)
for i in range(n-k+1):
  ans=max(ans, sexp[k+i]-sexp[i])
print(ans)

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

for i in range(n+1):
  if i+k<n+1:
    ans = max(ans,Sum[i+k]-Sum[i])
print(ans)

Solution (Python):
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p2 = [p[i]*0.5 + 0.5 for i in range(N)]
size = N + 1
cusum = [0] * size
max = 0

for i in range(N):
    cusum[i+1] = cusum[i] + p2[i]

for i in range(N-K+1):
    tmp = cusum[i+K] - cusum[i]
    if max < tmp:
        max = tmp
print(max)

Solution (Python):
from itertools import accumulate


N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2 for p in P]

cum = [0]
cum.extend(list(accumulate(E)))

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

print(ans)

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

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

def ex(p,n):
    return (p[n]+1)/2


list=[]
s=0
for i in range (0,N):
    s=s+ex(p,i)
    list.append(s)

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

Solution (Python):
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(), np.int64, sep=' ')

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum_list.max() + k) / 2

print(ans)

Solution (Python):
import sys
 
ma = {}
def _sum(n):
    if not n in ma:
        ma[n] = sum(range(1,n+1))
    return ma[n]

def ev(v):
    return _sum(v) * 1.0/v
 
N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]
 

cur = sum([p[i] for i in range(K)])
_max = cur

i = K-1
j = 0

while i < N - 1:
    cur -= p[j]
    i += 1
    j += 1
    cur += p[i]
    if _max < cur:
        _max = cur

print(_max)

Solution (Python):
N,K = map(int, input().split())
l = list(map(int,input().split()))
 
def E(n):
  return (1 + n) / 2
 
j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
elif N == K:
  l2 = list(map(E, l))  
  print(sum(l2))
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))
 
  print(sum(l2))

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

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

acum = [0]*(n+1)
for i in range(n):
  acum[i+1] = acum[i] + P[i]
  
total = [0]*(n-k+1)
for i in range(n-k+1):
  total[i] = acum[i+k]-acum[i]  
  
print(max(total))

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines






def main():
	n,k=map(int,input().split())
	p=list(map(int,input().split()))
	
	s=sum(p[:k])
	ans=s
	
	for i in range(n):
		try:
			s=s-p[i]+p[i+k]
			ans=max(ans,s)
		except:
			break
	
	print((ans+k)/2)
	
	
	
if __name__ == "__main__":
	main()

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


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

ans=Ary[K-1]
buf,left,right=0,0,0
for i in range(1,N-K+1):
    left,right=i,left+K
    
    buf=Ary[right]-Ary[left-1]
    if buf>ans:
        ans=buf
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
 
an=0
an2=0
t=0
 
for i in range(n):
    if i<k:
        an+=((p[i]+1)/2)
        an2=an
    else:
        t=((p[i-k]+1)/2)
        if an+((p[i]+1)/2)-t>an2:
            an2=an+((p[i]+1)/2)-t
        an=an+((p[i]+1)/2)-t
            
print(an2)

Solution (Python):
def kitai(n):
  return (int(n)+1)/2

import numpy as np
n,k=map(int,input().split())

L=np.array([list(map(kitai, input().split()))]).reshape(-1)

from itertools import accumulate

acc = [0]+ list(accumulate(L)) 
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)

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

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

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0] + [(1 + p) / 2 for p in P]
P_acc = list(accumulate(P))

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

print(ans)

Solution (Python):
def exp(a):
    return (a + 1) / 2

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

tmp = [0] * (n + 1) 
ans = 0

for i in range(1, n+1):
    if i <= k:
        tmp[i] = tmp[i-1] + exp(p[i-1])
    else:
        tmp[i] = tmp[i-1] - exp(p[i-k-1]) + exp(p[i-1])

print(max(tmp))

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

cuml=[]
cum=0
for i in range(n):
    cum+=(pl[i]+1)/2
    cuml.append(cum)
mx=0

for i in range(n-(k-1)):
    if i==0:
        mx=max(cuml[i+k-1],mx)
    else:
        mx=max(cuml[i+k-1]-cuml[i-1],mx)
print('{:.9f}'.format(mx))

Solution (Python):
import numpy as np

a1 = input()
a2 = input()

list1 = np.array(list(map(int,a1.split(" "))))

list2 = (np.array(list(map(int,a2.split(" "))))*10+10)/2

res = 0
now = 0

k = list1[1]
n = list1[0]
i = 0
while i < n:
    now = now + list2[i]
    if i>k-1:
        now = now - list2[i-k]
        res = max(res,now)
    res = max(res,now)
    i = i + 1
print(res/10)

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

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

t = sum(m[0:K])
result = t
for i in range(N - K):
    t += m[i + K] - m[i]
    if t > result:
        result = t
print(result)

Solution (Python):
from collections import deque

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

Ary=deque([])
ans,res,cnt=0,0,0
k=0

for i in range(N):
    cnt+=1
    k=(P[i]+1)/2
    Ary.append(k)
    res+=k
    if cnt<K:
        continue
    if ans<res:
        ans=res
    res-=Ary.popleft()

print(ans)

Solution (Python):
import sys
import numpy as np

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

p = np.array([list(map(int, input().split()))]).reshape(-1)

p_a = 0
p_r = p[:k]
for j in p_r:
    if j == 1:
        p_a += 1
    else:
        p_a += (j + 1) / 2
p_b = p_a
for i in range(1, n-k+1):
    if (p[i-1] == 1):
        p_b -= 1
    else:
        p_b -= (p[i-1] + 1) / 2

    if (p[i+k-1] == 1):
        p_b += 1
    else:
        p_b += (p[i+k-1]  + 1) / 2
    if p_b > p_a:
        p_a = p_b
print(p_a)

Solution (Python):
import sys
import numpy as np

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

p = np.array([list(map(int, input().split()))]).reshape(-1)

sum_max = p[:k].sum()
mx = sum_max
index_max = -1
for i in range(1, n-k+1):
    mx += p[i+k-1]
    mx -= p[i-1]
    if mx > sum_max:
        sum_max = mx
        index_max = i
print(str((sum_max+k) / 2))

Solution (Python):
n,k=list(map(int,input().split()))
p_list=[0]
for i,p in enumerate(input().split()):
    p_i = int(p)
    p_list.append(p_list[i] + (p_i+1)/2)

p_max=0
for i in range(k,n+1):
    p_max=max(p_max,p_list[i]-p_list[i-k])
print(p_max)

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

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

exp = 0
for i in range(k):
 exp += (1 + p[i]) / 2
 exp_true = exp

for i in range(n-k):
 exp += (1 + p[i+k]) / 2
 exp -= (1 + p[i]) / 2
 if exp_true < exp:
   exp_true = exp

print(exp_true)

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

s = 0
ans = 0

for i, j in enumerate(p):
    s+= (j+1)/2
    if i == k-1:
        ans = s
    if i > k-1:
        s -= (p[i-k]+1)/2
        ans = max(ans, s)
print(ans)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
res = 0
sum = 0
for i in range(N):
  sum += A[i]
  if i-K >= 0:
    sum -= A[i-K]
  res = max(res, sum)
print(0.5*(res+K))

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


c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = c_p[K - 1]

for i in range(K, N):
    e = c_p[i] - c_p[i - K]
    max_e = max(max_e, e)

print((max_e + K) / 2)

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

ma = sum(p[:K])
tmp = ma

for i in range(K,N):
    tmp += p[i]
    tmp -= p[i-K]
    if ma < tmp:
        ma = tmp

print((ma + K)/2)

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

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

s=[(p[n]+1)/2 for n in range(N)]
S=[0]*(N+1)

def make_S(n):
    S=[0]*(n+1)
    S[0]=0
    for i in range(n):
        S[i+1]=S[i]+s[i]
    return S
S=make_S(N)

def max_delta(n,k):
    max=-1000000
    for i in range(n-k+1):
        delta = S[i+k]-S[i]
        if delta>max:
            max=delta
    return max

print(max_delta(N,K))

Solution (Python):



def main():
    from itertools import accumulate

    n, k = map(int, input().split())
    p = [int(i) + 1 for i in input().split()]
    e = list(accumulate([0] + p))
    ans = 0

    for j in range(n - k + 1):
        ans = max(ans, e[j + k] - e[j])

    print(ans / 2)


if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
P = list(map(int,input().split()))
sum_a = 0
index = 0

for i in range(k):
    sum_a += P[i]
num = sum_a
for j in range(1,n-k+1):
    num += P[j+k-1]
    
    num -= P[j-1]
    
    if(sum_a<num):
        index = j
        sum_a = num

total = 0.0
for m in range(index,index+k):
    total += sum(list(range(P[m]+1)))/P[m]
print(total)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int,input().split()))
ans = 0
cum = [0]

for i in range(len(p)):
    ex = (1 + p[i])/2
    p[i] = ex
    
for i in  range(len(p)):
    cum.append(p[i] + cum[i])
    
for i in range(K, N+1):
    ans  = max(ans, cum[i] - cum[i-K])

print(ans)

Solution (Python):
all,rolls=map(int,input().split())
inputList=list(map(int,input().split()))

sum = 0
sumList =[]


for i in range(all):
	inputList[i] = (inputList[i] + 1) / 2


for i in range(rolls):
	sum = sum + inputList[i]
sumList.append(sum)


for i in range(all - rolls):
	sum = sum + inputList[i + rolls] - inputList[i]
	sumList.append(sum)

sumList.sort(reverse=True)
print(sumList[0])

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

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

curr_S = 0
count = 1
max_ev = 0
index = 0
has_eval_sk = False
zero_e = []
for p_str in input().split():
    e = (int(p_str)+1) / 2
    zero_e.append(e)
    if has_eval_sk:
        curr_S += e - zero_e[index]
        max_ev = max(max_ev, curr_S)
        index += 1
    else:
        curr_S += e
        if count == K:
            max_ev = curr_S
            has_eval_sk = True
        count += 1

print(max_ev)

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

M=S=sum(p[:K-1])
for i in range(K-1,N):
  S+=p[i]
  M=M if M>S else S
  S-=p[i-K+1]

print((M+K)/2)

Solution (Python):
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
sum = 0
for j in range(k):
  sum += lst[j]
max = sum
for i in range(n-k):
  sum = sum-lst[i]+lst[i+k]
  if max < sum:
    max = sum
print((max+k)/2)

Solution (Python):
n,m = list(map(int,input().split()))
lis = list(map(int,input().split()))
total = 0

for i in range(m):
  total += lis[i] * 0.5 + 0.5
ans = total

for k in range(m,n):
  total -= lis[k-m]/2 - lis[k]/2
  ans = max(ans,total)
  
print(ans)

Solution (Python):
n, m = map(int,input().split())
da = list(map(int,input().split()))
 
now = 0
for i in range(m):
    now += da[i]/2 + 0.5
ans = now
for i in range(m,n):
    now -= da[i-m]/2 - da[i]/2
    ans = max(ans, now)
print(ans)

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

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

max = 0
for i in range(n-k+1):
  if i == 0:
    s = sum(ps[i:i+k])
  else:
    s = s - (ps[i-1] - ps[i+k-1])
  if s > max:
    max = s
print((max + k) / 2)

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

sum_a = sum(box[:K])
max_a = sum_a
for i in range(N-K):
    max_a -= box[i]
    max_a += box[i+K]
    if max_a > sum_a:
        sum_a = max_a

print(sum_a)

Solution (Python):


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

e = []
for i in range(len(p)):
    e.append((p[i] + 1) / 2)

cum = [0]
for i in range(len(e)):
    cum.append(e[i] + cum[i])

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

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
max = 0
S = 0
for i in range(len(P)):
    S += P[i]
    if i-K < 0:
        pass
    else:
        S -= P[i-K]
    if max < S:
        max = S

print((max+K)/2)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp

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


print((res + k) / 2)

Solution (Python):
n,k=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(n+1)
S[1]=P[0]

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

ma=0
for i in range(k,n+1):
    s=S[i]-S[i-k]
    ma=max(ma,s)
print((ma+k)/2)

Solution (Python):

a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(i + 1) / 2 for i in c]
e = sum(d[:b])
f = e
for i in range(a - b):
	f -= d[i]
	f += d[i + b]
	if f > e:
		e = f
print(e)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

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

sk = sum(P[:K])
n = sum(P[:K])
for i in range(N):
    if i < K:
        continue

    n -= P[i - K]
    n += P[i]

    sk = max(sk, n)
    prev = n

ans = sk / 2. + K / 2.
print(ans)

Solution (Python):
n,k  = map(int,input().split())
p = list(map(int, input().split()))
current_best = 0
sum_list = [(1+p[0])/2]

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


for i in range(n-1):
  sum_list.append(sum_list[-1]+(1+p[i+1])/2)
  
if n==k:
  print(sum_list[-1])
  exit()
  
for j in range(n-k):
  expect = sum_list[j+k]-sum_list[j]
  if expect > current_best:
    current_best = expect
print(current_best)

Solution (Python):
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

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

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

Solution (Python):
nk  = list(map(int,input().split()))
p = list(map(int,input().split()))
s = [0] * (nk[0])
for j in range(nk[1]):
    s[0] += p[j]

for i in range(nk[0]-nk[1]):
    s[i+1] = s[i] - p[i] + p[i+nk[1]]

print((max(s)+nk[1])/2)

Solution (Python):



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

rui=[]
rui.append(p[0]/2+0.5)
for i in range(1,n):
    rui.append(rui[i-1]+(p[i]/2+0.5))


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

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

if __name__ == '__main__':
    main()

Solution (Python):

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

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

ans = 0
tmp = 0
for i in range(k):
    tmp += kitai[i]
ans = tmp
for i in range(n - k):
    tmp = tmp - kitai[i] + kitai[i + k]
    if ans < tmp:
        ans = tmp
print(ans)

Solution (Python):
def main():
    
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    answer = sum(p[:K])
    tmp = sum(p[:K])
    for i in range(N - K):
        tmp = tmp + p[i+K] - p[i]
        answer = max(answer, tmp)
    print((answer + K) / 2)


if __name__ == '__main__':
    main()

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

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

E = 0
prog = sum(P_E[0:K])
max = prog
for i in range(N - K):
    prog += P_E[i + K] - P_E[i]
    if prog > max:
        max = prog
    else:
        pass
    
print(max)

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

Solution (Python):
x,y = map(int,input().split())
t = list(map(int,input().split()))
sum = 0

for i in range(y):
    sum += (t[i]+1)*0.5

mx = sum

for i in range(y, x):
    sum = sum + (t[i]+1)*0.5 - (t[i-y]+1)*0.5
    mx = max([sum, mx])

print(mx)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = 1+P
    kitaichi.append(kitai)
m = [0,]
a = 0
for j in range(n):
    a += kitaichi[j]
    m.append(a)
ans = 0
for l in range(n-k+1):
    temp = m[l+k]-m[l]
    if temp> ans:
      ans = temp
print(ans/2)

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

a = 0
for i in range(N - K + 1):
  if i == 0:
    b = sum(p[0:K])
  else:
    b = b - p[i-1] + p[i + K - 1]
  
  if b > a:
    a = b
    f = i

ans = 0
for j in range(K):
  ans += (p[f + j] + 1) / 2

print(ans)

Solution (Python):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

import itertools




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *P = map(int, read().split())
R = list(itertools.accumulate(P))
ans = 0
for i in range(K - 1, N):
    if i - K >= 0:
        s = ((R[i] - R[i - K]) + K) / 2
    else:
        s = (R[i] + K) / 2
    ans = max(s, ans)
print('{:.6f}'.format(ans))

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

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

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

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

wa = sum(p_list[0:k])
ans = wa

for j in range(n-k):
    wa = wa + p_list[j+k] - p_list[j]
    ans = max(ans, wa)
    
print(ans)

Solution (Python):
import itertools

N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
S = [0]+[E for E in itertools.accumulate(P)]
ans = 0
for j in range(N-K+1):
    e = S[j+K]-S[j]
    if ans < e:
        ans = e
print(ans)

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

''' 累積和 '''
cumulative_sum = [P[0]]
for i in range(len(P)-1):
    cumulative_sum.append(cumulative_sum[i] + P[i+1])











''' 最大値探索 O(N-K) '''

max = cumulative_sum[K-1]
max_index = 0
for i in range(N-K):
    now = cumulative_sum[K+i] - cumulative_sum[i]
    if max < now:
        max = now
        index = i




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

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

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

d=sum(p[:K])
ans=d
for i in range(K,N):

    d = d + p[i]-p[i-K]
    ans = max(ans, d)
   
print((ans+K)/2)

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

l=[0]*n
sum1=0
for i in range(n):
    sum1+=exp[i]
    l[i]=sum1 

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

Solution (Python):
import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) 

l=np.cumsum(exp) 

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

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

p = [0]
for i in range(N):
    p.append(p[-1] + (P[i] + 1) / 2)

print(max([p[j + K] - p[j] for j in range(N - K + 1)]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
m = s = sum(p[0:k])
for p_old, p_new in zip(p, p[k:]):
  s += p_new - p_old
  m = max(m, s)
print((m+k)/2)

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


A = [0]
for i in P:
    A.append(A[-1]+i)

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

Solution (Python):
N,K = (int(x) for x in input().split())
P = list(int(x) for x in input().split())

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

total1 = 0

for i in range(K):
    total1 += P[i]

ans = total1
total2 = 0

for i in range(N-K):

    total1 += P[K+i]
    total2 += P[i]
    
    if ans < total1 - total2:
        ans = total1 - total2


print(ans)

Solution (Python):

N,K = map(int, input().split())
P = [int(i) for i in input().split()]
 
expect = (sum(P[0:K])+K)/2
ma = expect
for i in range(K,N):
  expect += (P[i]-P[i-K])/2
  if ma < expect:
    ma = expect
print(ma)