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())
l=list(map(int,input().split()))
maxi=0
suml=sum(l[:k])
maxl=sum(l[:k])
for i in range(n-k):
    if suml-l[i]+l[k+i]>maxl:
        maxl=suml-l[i]+l[k+i]
        maxi=i+1
    suml=suml-l[i]+l[k+i]
sumsum=0
for j in range(maxi,maxi+k):
    sumsum+=(l[j]+1)/2
print(sumsum)

Solution (Python):
def main():
    """"ここに今までのコード"""
    N, K = map(int, input().split())
    dice_list = list(map(int, input().split()))
    max, s = 0, 0

    for i in range(K):
        s += (dice_list[i] + 1) / 2
    
    max = s

    for i in range(N-K):
        s -= (dice_list[i] + 1) / 2
        s += (dice_list[i+K] + 1) / 2
        if s > max:
            max = s
    
    print(max)


if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, K = LI()
    P = LI()

    cum = 0
    for i in range(K):
        cum += (P[i] + 1) / 2

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy









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

print(ans)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
from itertools import accumulate
acc=[0]+list(accumulate(P))
print((max(b-a for a,b in zip(acc,acc[K:]))+K)/2)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
from itertools import accumulate
acc=[0]+list(accumulate(P))
print((max(b-a for a,b in zip(acc,acc[K:]))+K)/2)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
from itertools import accumulate
acc=[0]
acc.extend(accumulate(P))
ans=0
for i in range(N-K+1):
  exp=(acc[K+i]-acc[i]+K)/2
  ans=max(exp,ans)
print(ans)

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

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

jj = 0
koho=[]
for i in range(K):
    jj+=arr[i]
    koho.append(jj)

for i in range(N-K):
    jj+=arr[i+K]
    jj-=arr[i]
    koho.append(jj)

a=max(koho)
print(a/2+(K/2))

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

ksum = [0 for _ in range(N-K+1)]
ksum[0] = sum(p[:K])
for i in range(N-K):
    ksum[i+1] = ksum[i] - p[i] + p[i+K]

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

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
acc = [0] + list(accumulate(P))
print((max(b - a for a, b in zip(acc, acc[K:])) + K) / 2)

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
acc = [0] + list(accumulate(P))
ans = 0
for a, b in zip(acc, acc[K:]):
  exp = (b - a + K) / 2
  ans = max(exp, ans)
print(ans)

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

probs = list(itertools.accumulate([(1+p)/2 for p in P]))
probs.insert(0,0)

ans = 0

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

print(ans)

Solution (Python):
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    for p in P:
        
        
        exp += (1+p)/2
        p_e.append(exp)
    
    maxv = p_e[k-1] - 0
    for i in range(1, n-k):
        
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)
if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate

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

xs = [0] + list(accumulate(map(lambda v: (1 + v) * v // 2 / v, p)))
ans = 0
for i in range(n - k + 1):
    ans = max(ans, xs[i + k] - xs[i])
print(ans)

Solution (Python):
n, k = map(int, input().split())
P = [int(x) for x in input().split()]
p_e = list()
exp = 0
for p in P:
    
    
    exp += (1+p)/2
    p_e.append(exp)  


if n == k:
    print(p_e[-1])
else:
    
    maxv = p_e[k-1] - 0
    for i in range(1, n-k):
        
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

Solution (Python):
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    
    
    
    
    
    
    
    
    
    for p in P:
        
        
        exp += (1+p)/2
        p_e.append(exp)  
    if n == k:
        print(p_e[-1])
    else:
        
        maxv = p_e[k-1] - 0
        for i in range(1, n-k):
            
            p_sum = p_e[k+i] - p_e[i]
            maxv = max(maxv, p_sum)
        print(maxv)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    p_e.append(exp)
    for p in P:
        exp += (1+p)/2
        p_e.append(exp)
    maxv = p_e[k] - p_e[0]
    for i in range(1, n-k+1):
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    for p in P:
        
        
        exp += (1+p)/2
        p_e.append(exp)  
    if n == k:
        print(p_e[-1])
    else:
        
        maxv = p_e[k-1] - p_e[0]
        for i in range(1, n-k):
            
            p_sum = p_e[k+i] - p_e[i]
            maxv = max(maxv, p_sum)
        print(maxv)

if __name__ == '__main__':
    main()

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


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


from itertools import accumulate
cum = [0] + list(accumulate(l))


sum_k = []
for j in range(n-k+1):
    sum_k.append(cum[k+j] - cum[j])

print(max(sum_k))

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

han=-32
saigou=sum(X[N-K:N])
han=saigou
for a in range(N-K-1):

    if gou>han:
        han=gou
    gou=gou-X[a]+X[a+K]

print(han)

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

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


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

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

Solution (Python):
from itertools import accumulate

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

Solution (Python):









import os
import sys


from itertools import accumulate


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    s = [(x+1)/2 for x in p]

    s = list(accumulate(s))
    s.insert(0, 0)
    ans = 0

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



if __name__ == "__main__":
    main()

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


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


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

Solution (Python):
import collections

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


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


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

Solution (Python):
import copy

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

s = sum(p[:k])
smax = copy.deepcopy(s)
for i in range(n-k):
    s += p[i+k] - p[i]
    smax = max(smax, s)

print((smax+k)/2)

Solution (Python):


def calcExpectedValue(prob):
  return (prob+1)/2

def solve(n,k,p):
  expLst = [calcExpectedValue(prob) for prob in p]
  cum = [0]*(n+1)
  for i in range(n):
    cum[i+1] = cum[i] + expLst[i]
  ans = 0
  i = 0
  while i+k <= n:
    ans = max(ans,cum[i+k]-cum[i])
    i += 1
  return ans




def main():
  N,K = map(int,input().split())
  p = list(map(int,input().split()))
  print(solve(N,K,p))
  return

if __name__ == '__main__':
  main()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    1 2
    /2 = 1.5

    1 2 3 4
    /4 = 2.5

    1 2 3 4 5
    /5 = 3
    """
    N, K = read_ints()
    expectations = [(p+1)/2 for p in read_ints()]
    max_e = current = sum(expectations[:K])
    for i in range(1, N-K+1):
        
        current = current-expectations[i-1]+expectations[i+K-1]
        max_e = max(max_e, current)
    return max_e


if __name__ == '__main__':
    print(solve())

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

Solution (Python):
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 = sum(p[0:k])
maxm = m

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

print(maxm)

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,k = I2()
    p = Intl()
    s = 0
    for i in range(k):
        s += (p[i] + 1)/2
    ans = s
    for i in range(k,n):
        s += (p[i] + 1)/2
        s -= (p[i-k] + 1)/2
        ans = max(ans,s)
    print(ans)

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

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

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

n,k=map(int,input().split())
L=list(map(int,input().split()))
M=[(1+i)/2 for i in L]
N=[0]+list(accumulate(M))
ans = 0
for i in range(k,n+1):
    val = N[i]-N[i-k]
    ans = max(val,ans)
print("%.6f"%ans)

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

Solution (Python):
import numpy as np
n, k = map(int, input().split())
P = list(map(int, input().split()))
P = list(map(lambda x: (x + 1) * x / 2 / x, P))
P = np.array([0] + P)
P = np.cumsum(P)
ans = np.zeros(n - (k - 1))
for i in range(n - (k - 1)):
    ans[i] = P[k + i] - P[i]
print(np.max(ans))

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

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

p_rui = [pp[0]]
for i in range(1,n):
    p_rui.append(p_rui[i-1]+pp[i])



walist=[p_rui[k-1]]
for i in range(0,n-k):
    walist += [p_rui[k+i]-p_rui[i]]

print(max(walist))

Solution (Python):

n, k, *P = map(int, open(0).read().split())
p = [(i + 1) / 2 for i in P]
s = [float()]
for i in range(n):
    s.append(s[i] + p[i])
print(max(s[i + k] - s[i] for i in range(n - k + 1)))

Solution (Python):

n, k, *P = map(int, open(0).read().split())
p = [(i + 1) / 2 for i in P]
s = [float()]
for i in range(n):
    s.append(s[i] + p[i])
print(max(s[i + k] - s[i] for i in range(n - k + 1)))

Solution (Python):

n, k, *P = map(int, open(0).read().split())
p = [(i + 1) / 2 for i in P]
c = sum(p[:k])
ans = c
for i in range(n - k):
    c = c + p[i + k] - p[i]
    ans = max(c, ans)
print(ans)

Solution (Python):
from itertools import accumulate

N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(lambda x: (x+1)/2, P))

Q_cum = list(accumulate([0] + Q))
res = 0
for i in range(N-K+1):
    temp = Q_cum[i+K]- Q_cum[i]
    res = max(res, temp)
print(res)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
prospect = []
for k in range(N):
  if p[k]%2 == 1:
    prospect.append((p[k]+1)>>1)
  else:
    prospect.append((p[k]+1)/2)
S = sum(prospect[:K])
ans = 0 + S
for k in range(N-K):
  S += prospect[k+K] - prospect[k]
  ans = max(ans, S)
print(ans)

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


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

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

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

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

  print(max_)


if(__name__ == '__main__'):
  main()

Solution (Python):

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 = sum(p[:k])

    current = sum(p[:k])

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

    print((max_seq + k) / 2)


main()

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

Solution (Python):
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()
x = list(itertools.accumulate(p))

if n==1:
    print((p[0]+1)/2)
    sys.exit()

if n==k:
    print((x[-1]+k)/2)
    sys.exit()

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

print((ans+k)/2)

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

    E=[]

    for i in p:
        E.append((1+i)/2)

    S=[0]

    s=0
    for i in E:
        s+=i
        S.append(s)

    max=0
    right=0
    left=right+K

    while left<len(S):
        res=S[left]-S[right]
        if res>=max:
            max=res
        right+=1
        left=right+K

    print(max)

if __name__=="__main__":
    main()

Solution (Python):
n, k = map(int, input().split())
list_P = list(map(int, input().split()))
cnt = 0

for i in range(k):
    p = list_P[i]
    cnt += (1+p)/2

ans = cnt
for i in range(k, n):
    p, q = list_P[i-k], list_P[i]
    cnt -= (1+p)/2
    cnt += (1+q)/2
    ans = max(ans, cnt)

print(ans)

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

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

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

N,K = LI()
p = LI()
E_half = np.array(p) + 1

def main():
    Pcum = np.zeros(N + 1, np.int32)
    Pcum[1:] = E_half.cumsum()
    
    
    partial_sums_E_half = np.zeros(N-K+1, np.int32)
    for i in range(N-K+1):
        partial_sums_E_half[i] = Pcum[i+K] - Pcum[i]

    
    return (partial_sums_E_half.max())/2
print(main())

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

sum_k = sum( p[ : k ] )
max_sum_k = sum_k

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

print( ( max_sum_k + k ) / 2 )

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

s = [0] * (n + 1)
for i in range(n):
    a = p[i] * (p[i] + 1) // 2
    e = a / p[i]
    s[i + 1] = s[i] + e

ans = 0
for i in range(n - k + 1):
    ans = max(ans, s[i + k] - s[i])
print('{:.12f}'.format(ans))

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ps = [p[0]] + [0]*(n-1)
for i in range(1,n):
    ps[i] = ps[i-1] + p[i]
maxs = ps[k-1]
for i in range(1,n-k+1):
    maxs = max(maxs,ps[i+k-1]-ps[i-1])

print((maxs+k)/2)

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

for i, j in enumerate(p):
    p[i] = (j*(j+1)/2) / j 
t_sum = sum(p[:k])
ans = t_sum
for i in range(n-k):
    t_sum = t_sum - p[i] + p[i+k]
    if ans < t_sum:
        ans = t_sum
print(ans)

Solution (Python):
n,k=map(int,input().split())
c=list(map(int,input().split()))
a=[]
for x in range(n):
  s=c[x]
  t=(s+1)/2
  a.append(t)
  
ans=0
b=[]
b.append(a[0])

for y in range(n-1):
  c=b[y]
  d=b[y]+a[y+1]
  b.append(d)
  
dd=b[k-1]
for z in range(1,n+1-k):
  e=b[z+k-1]-b[z-1]
  
  dd=max(dd,e)

print(dd)

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

Solution (Python):
from itertools import accumulate

N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) + 1, input().split()))
P_cumsum = [0] + list(accumulate(P))
print(max([P_cumsum[i+K]-P_cumsum[i] for i in range(N-K+1)])/2)

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

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

M=-1
for j in range(N-K+1):
    M=max(M,S[j+K]-S[j])
print((M+K)/2)

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

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

EV_acc = [0] + list(itertools.accumulate([(i+1)/2 for i in p]))

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = lambda x: 0.5*(x+1)
if k == 1:
    res = e(max(p))
else:
    s = [0]
    s[0] = sum(p[:k])
    for i in range(1, n-k+1):
        s.append(s[i-1] - p[i-1] + p[i+k-1])
    idx = s.index(max(s))
    res = sum([e(p[i]) for i in range(idx, idx+k)])
print(res)

Solution (Python):


import itertools





def main():
    n, k = input_list()
    a = input_list()
    kitais = [0]
    for i in range(n):
        kitai = (a[i]+1)/2
        kitais.append(kitais[i] + kitai)
    ans = 0
    for i in range(n-k+1):
        ans = max(ans, kitais[i+k] - kitais[i])
    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()

Solution (Python):
import sys

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

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

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


cs = [0]*n
cs[0] = tmp[0]
for i in range(len(tmp)-1):
    cs[i + 1] = cs[i] + tmp[i + 1]

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

Solution (Python):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

tmp = [(i+1)/2 for i in p]
cs = list(np.cumsum(tmp))

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

Solution (Python):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

l = [i for i in range(1, 1001)]
av = np.cumsum(l) / l

tmp = [av[i - 1] for i in p]
cs = list(np.cumsum(tmp))

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

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

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

print((K+mmax)/2)

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 

 










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

S = []

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

tmp = sum(S[:K])
ans = tmp

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


print(ans)

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

from itertools import accumulate
acc = list(accumulate(p))

ans = 0
for st in range(n-k+1):
    ans=max(acc[k+st]-acc[st],ans)
    
print((ans+k)/2)

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

ans = 0.0
k = 0
v = 0.0
for i in range(N):
    v += (P[i] + 1) / 2
    k += 1
    if k > K:
        v -= (P[i-K] + 1) / 2
        k -= 1
    ans = max(ans, v)
print(ans)

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

Solution (Python):
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):
    return n*(n+1)/2/n
    ans = 0
    for i in range(1, n+1):
        ans += i/n
    return ans


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


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

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

values = [0]

for p in P:
    values.append(values[-1] + (p * (p + 1) // 2 / p))

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

print(ans)

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

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

Solution (Python):
from itertools import accumulate
n,k = map(int,input().split())
l = [0] + list(map(int,input().split()))
for i in range(n):
    l[i+1] = (l[i+1]+1)/2
acc = list(accumulate(l))

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

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

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

sum1 = sum(p[:k])
num = k-1
max1 = sum1

for i in range(k,n):
    sum1 = sum1 - p[i-k] + p[i]
    if sum1 >= max1:
        max1 = sum1
        num = i
    

sum2 = sum(p[num-k+1:num+1])

def goukei(j):
    return 1/2 * j * (j+1)

print(float((goukei(sum2)-goukei(k-1))/(sum2 -k +1)))

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n, k = [int(x) for x in input().split()]
    p = [int(x) for x in input().split()]
    a = [(x+1)*x//2/x for x in p]
    ans = 0
    sm = 0
    for i in range(n):
        sm += a[i]
        if i + 1 >= k:
            ans = max(ans, sm)
            sm -= a[i - k + 1]
    print(ans)



    

t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

Solution (Python):
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()))))
cnt = sum(p[0:k])
ans = cnt
for i in range(k, n):
    cnt += p[i] - p[i - k]
    ans = max(ans, cnt)
print(ans)

Solution (Python):
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 = sum(pn1[:K])
spb = ans
for i in range(N-K):
    sp = spb -pn1[i] + pn1[i+K]
    
    ans = max(sp,ans)
    spb = sp
print(ans/2+K)

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

Solution (Python):
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))

s = sum(cb[:b])
l.append(s)

for i in range(b,a):
    s = s - cb[i-b] + cb[i]
    l.append(s)

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

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = tuple(accumulate(map(int, input().split())))
ans = P[K - 1]
for i in range(N - K):
  ans = max(P[i + K] - P[i], ans)
print((ans + K) / 2)

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

S = [0]
sum_ = 0
for i, p in enumerate(P):
  sum_ += p
  S.append(sum_)


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

res = (max_sum + K) / 2

print(res)

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

ex=[0]*1001
tmp=0
for i in range(1,1001):
  tmp+=i
  ex[i]=tmp/i

sumEx=[0]*(n+1)
for i in range(n):
  sumEx[i+1]=sumEx[i]+ex[p[i]]

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

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

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    e_value = [(1 + i)/2 for i in p]
    c_value = [e_value[0]]
    for i in range(1, n):
        c_value.append(c_value[i-1] + e_value[i])
    ans = 0
    for i in range(k-1, n):
        if i == k-1:
            ans = c_value[i]
        else:
            ans = max(ans, c_value[i]-c_value[i-k])
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
P = tuple(map(int, input().split()))
P2 = P[K:]

max_sum = 0
sum_ = sum(P[:K])

for p, q in zip(P, P2):
  max_sum = max(max_sum, sum_)
  sum_ += q - p
  
max_sum = max(max_sum, sum_)
          
res = (max_sum + K)/ 2
print(res)