Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Accepted

Solution code:
#n = int(input())
#s = input()
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
data = [(x+1)/2 for x in p]
#print(data)
ans = sum(data[:k])
now = ans

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

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


N,K = map(int,input().split())
A = list(map(int,input().split()))
def it():
    c = sum(A[:K])
    yield c
    for i in range(K,N):
        c += A[i]
        c -= A[i-K]
        yield c

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

Submission status: Accepted

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

Submission status: Accepted

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

L = [0] * N

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

ans = 0

k = 0
for i in range(K):
  k += L[i]

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import accumulate as acc

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

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

l = [0] + list(acc(p))

max_num = 0
for i in range(N-K+1):
    s = l[i+K] - l[i]
    max_num = max(s, max_num)

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

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

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

from itertools import accumulate

S=[0]+list(accumulate(V))

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

print(ANS)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
exp = [(int(x)+1)/2 for x in input().split()]

tmp = sum(exp[:k])
ans = tmp

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

print(ans)

Submission status: Accepted

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

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

f = sum(e[:K])
ans = f

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

print(ans)

Submission status: Accepted

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

s = sum(p[:k])
s += k
s /= 2
ans = s

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=float)

E = (A + 1) * 0.5
cumE = np.zeros(N + 1, dtype=float)
cumE[1:] = E.cumsum(axis=0)

ans = (cumE[K:] - cumE[:-K]).max()
print(ans)

Submission status: Accepted

Solution code:

n,k = map(int,input().split())
P = list(map(int,input().split()))
Q = []
for i in range(n):
    Q.append((P[i]-1)/2 + 1)
R = [Q[0]]
for i in range(1, n):
    R.append(R[-1] + Q[i])
l = 0
r = R[k-1]
ans = r-l
for i in range(n-k):
    ans = max(ans, R[k+i]-R[i])
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, K: int, p: "List[int]"):

    acc = [0]+list(accumulate(p))
    m, mi = 0, 0
    for i in range(N-K+1):
        if acc[i+K]-acc[i] > m:
            m = acc[i+K]-acc[i]
            mi = i
    print((m+K)/2)
    return


def main():

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

now = 0

for i in range(N):

    if i < K-1:
        now += (1+p[i])

    else:
        now += (1+p[i])

        ans = max(ans,now)

        now -= (1 + p[i-(K-1)])

print (ans / 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

n, k = na()
ps = na()

cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + ps[i]

mx = 0
for i in range(n-k+1):
    mx = max(mx, cum[i+k] - cum[i])
print("{:.14f}".format((mx + k) / 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
    c.append(c[-1] + q)

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

Submission status: Accepted

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

s = sum(p[:K])
m = s
for i in range(K, N):
  s += p[i]
  s -= p[i-K]
  m = max(m, s)
print "%.10f"%((m+K)*.5)

Submission status: Accepted

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

Submission status: Accepted

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

N, K = map(int, input().split())
p = list(map(int, input().split()))
a = [(pi+1)/2 for pi in p]
acc = [0]

for ai in a:
    acc.append(acc[-1]+ai)
    
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    p=list(map(int,input().split()))
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=S[i]+p[i]
    ans=float(0)
    for i in range(N-K+1):
        tmp=(S[i+K]-S[i]+K)/2
        ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [(a[i]+1)/2 for i in range(n)]
acc = [0]+list(accumulate(a))
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read


n,k,*p = [int(i) for i in read().split()]


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


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

print(m/2)

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

n,k=LI()
a=[(1+i)/2 for i in LI()]
ac=[0]
for i in range(n):
    ac+=[ac[-1]+a[i]]

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

print(ans)

Submission status: Runtime Error

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

for i in range(0,n-n%k):
    sum = 0
    for j in range(i,i+k):
        sum += p[j]
    if sum > max:
        e = []
        for j in range(i, i+k):
            e.append(p[j])

for i in range(k):
    x = 0
    for j in range(e[i]+1):
        x += j
    x /= e[i]
    ans += x    

print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

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

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

for i in range(K,N):
    T[i] = P[i] - P[i-K]

T = T[K:]

if N == 1:
    print(P[i])
else:
    print(max(T))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

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

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

for i in range(K,N):
    T[i] = P[i] - P[i-K]

T = T[K:]

print(max(T))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1000
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
for j in range(N-K+1):
  if j == 0:
    mid = midList[j+K-1]
  else:
    mid = midList[j+K-1]- midList[j-1] 
  res = max(res,mid)
print(res)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1000
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
for j in range(N-K+1):
  if j == 0:
    mid = midList[j+K]
  else:
    mid = midList[j+K-1]- midList[j-1] 
  res = max(res,mid)
print(res)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reversed=True)

l=l[0:k]
max_l=max(l)

num=0
sum_lis=[]
for i in range(1,max_l+1):
  num+=i
  sum_lis.append(num)
  
ans=0
for i in l:
  a=sum_lis[i-1]
  ans+=(a/i)
  
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reversed=True)

l=l[0:k]
max_l=max(l)

num=0
sum_lis=[]
for i in range(1,max_l+1):
  num+=i
  sum_lis.append(num)
  
ans=0
for i in l:
  a=sum_lis[i-1]
  ans+=(a/i)
  print(ans,i,a)
  
print(ans)

Submission status: Runtime Error

Solution code:
N, K] = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
E = []

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

t = 0
for i in range(N-K+1):
    x = sum(E[i:i+K])
    if t < x:
        t = x

print(t)

Submission status: Runtime Error

Solution code:
[N, K] = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
E = []

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

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

print(max(S))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
maxv = 0
maxi = None
for i in range(0, len(P)-k):
    b = sum(P[i:i+k])
    if maxv < b:
        maxv = b
        maxi = i


ans = 0
for i in P[maxi:maxi+k]:
    ans += sum(list(range(1, i+1))) / i
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
max = sum(p[0:k])
tmp = max
idx = 0
for i in range(1, len(p) - k + 1):
	tmp -= p[i - 1]
	if i + k - 1 < len(p):
	    tmp += p[i + k - 1]
	if tmp > max:
		max = tmp
		idx = i
lst = p[idx:idx+k]

total_tasu = 0
total_kake = reduce(lambda a, b: a*b, lst)
for i, v in enumerate(lst):
	kake = total_kake / v
	total_tasu += sum([k for k in range(1, v + 1)]) * kake
print(total_tasu/total_kake)

Submission status: Runtime Error

Solution code:
import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


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

exps = [get_exp_value(i) for i in range(100)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)

Submission status: Runtime Error

Solution code:
import os, sys, re, math

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

def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp

exps = [get_exp_value(i) for i in range(200001)]

max_sum = sum(P[0:K])
max_pos = 0
for i in range(K, N):
    s = max_sum - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i - K

answer = 0
for i in range(max_pos, max_pos + K):
    answer += get_exp_value(P[i + 1])
    #answer += exps[P[i + 1]]

print(answer)

Submission status: Runtime Error

Solution code:
import os, sys, re, math

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

def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp

exps = [get_exp_value(i) for i in range(200001)]

max_sum = sum(P[0:K])
max_pos = 0
for i in range(K, N):
    s = max_sum - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i - K

answer = 0
for i in range(max_pos, max_pos + K):
    #answer += get_exp_value(P[i + 1])
    answer += exps[P[i + 1]]

print(answer)

Submission status: Runtime Error

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

p_list_E = []
p_list_E_temp = [1, 1.5, 2, 2.5, 3, 3.5]

for i in range(len(p_list)):
    p_list_E.append(p_list_E_temp[p_list[i]-1])
#print(p_list_E)

p_list_sum = [0]
for i in range(0,N):
    p_list_sum.append(p_list_sum[i]+p_list_E[i])
#print(p_list_sum)

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

Submission status: Runtime Error

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

A = list(accumulate(P))

largest = A[2]
point = 0
for i in range(K, N):
    if largest < A[i] - A[i-K]:
        largest = A[i] - A[i-K]
        point = i

ans = 0
for j in range(point - K + 1, point+1):
    p = P[j]
    ans += (((p + 1) * p) / 2) / p

print(ans)

Submission status: Runtime Error

Solution code:
import sys

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[(1+p)/2 for p in P]
temp=sum(Q[:K])
ans=temp
for i in range(N-3):
  temp=temp-Q[i]+Q[i+K]
  ans=max(ans,temp)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
import sys

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[(1+p)/2 for p in P]
temp=sum(Q[:K])
ans=temp
for a,i in enumerate(range(N-4)):
  temp=temp-Q[i]+Q[i+K]
  ans=max(ans,temp)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=P.sort(reverse=True)
P=P[:K]
ans=0

for p in P:
  ans+=(1+p)/2
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

rui=[0]
for i in a:
  rui.append(rui[-1]+i)
hantei=0
for i in range(1,len(rui)-k):
  if hantei<=rui[i+k]-rui[i]:
    hantei=rui[i+k]-rui[i]
    l=i
    r=i+k
ans=0
for i in range(l,r):
  ans+=(a[i]+1)/2
  
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
li.sort(reverse=True)
ans=0
for i in li[:k]:
  ans+=kai(i)/i
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=[int(s) for s in input().split()]
b=[0]*k
c=0
v[0]=a[0]
for i in range(n):
    v[i+1]=v[i]+a[i+1]
mx=v[2]
for i in range(3,n):
    g=v[i]-v[i-2]
    mx=max(mx,g)  
    
print((mx+1)/2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


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


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

    p_ev = list(map(ev, p))

    s = np.cumsum(p_ev)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k-1] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


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


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

    p_ev = list(map(ev, p))

    s = np.cumsum(p_ev)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


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


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

    p_ev = list(map(ev, p))

    s = np.cumsum(p)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


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


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

    p_ev = list(map(ev, p))

    s = np.cumsom(p)

    ans = []

    for i in range(n - k):
        ans.append(s[i + k] - s[i])

    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


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


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

    s = []

    p_ev = list(map(ev, p))

    for i in range(1, n+1):
        s.append(sum(p_ev[:i]))

    ans = []

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

a = [0] * N+1
a[0] = l[0]
for i in range(1,len(l)):
    a[i] = a[i-1] + l[i]

ans = 0
for i in range(K,len(l)):
    ans = max(ans,a[i]-a[i-K])

print(ans)

Submission status: Runtime Error

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

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

ans=0

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

Submission status: Runtime Error

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

import numpy as np

Q = np.argmax([sum(P[i:i+K]) for i in range(N-K)])

Q = [sum(P[:K])]
for i in range(1,N-K+1):
    Q.append(Q[i-1]+P[K+i-1]-P[i-1])
a = np.argmax(Q)

ans = sum([(1.00+P[a+j])/2.00 for j in range(K)])

print(ans)

Submission status: Runtime Error

Solution code:
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):
        # 隣接するk個の期待値の和
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    exp = list()
    for p in P:
        # 期待値
        exp.append((1+p)/2)
    p_e = list()
    e_cum = 0
    for i in exp:
        # 累積和
        e_cum += i
        p_e.append(e_cum)
    # maxv = 0
    maxv = p_e[k] - p_e[0]
    for i in range(1, n-k):
        # 隣接するk個の期待値の和
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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] - p_e[0]
    for i in range(1, n-k):
        # 隣接するk個の期待値の和
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
# 期待値:マス目の総和／マス目の数, マス目の最大値+最小値[1]／2
l = [(i+1)/2 for i in l] # 期待値に変換

# 累積和を取得
from itertools import accumulate
cum = list(accumulate(l))
# 差分を考慮しつつ k個の和をリストする → 最大値が ans
sum_k = []
for j in range(n-k):
    sum_k.append(cum[k+j] - cum[j])

print(max(sum_k))

Submission status: Runtime Error

Solution code:
from itertools import accumulate

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

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
q=[]
for i in range(len(p)):
  q.append(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)

Submission status: Runtime Error

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

S = []
pre = 0
for i in range(n):
    E = (p[i]+1.0) / 2.0
    E += pre
    S.append(E)
    pre = E
    
ans = 0
for j in range(n-k+1):
    now = S[j+k] - S[j]
    ans = max(ans, now)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

cb = list(map(abc,c))

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

S = []
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)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = []
for i in range(K-1):
   T = p[i:i+K]      
   ans.append(sum(T)/2+0.5*K)
print(ans[-1])

Submission status: Runtime Error

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


s=[]
p=np.array(p)
sum=0
for i in range(n):
  sum+=(1+p[i])/2
  s.append(sum)
  
max=s[k]-s[0]
for j in range(1,n-k):
  #print(j)
  if max<= s[j+k]-s[j]:
    max=s[j+k]-s[j]
  
print(max)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
Ex = []
for p in P:
    Ex.append(0.5*(p+1))
Ex_sum = []

e=0
for i in range(N):
    e += Ex[i]
    Ex_sum.append(e)

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

Submission status: Runtime Error

Solution code:

N,K = map(int,input().split())
P = list(map(int,input().split()))
Ex = []
for p in P:
    Ex.append(0.5*(p+1))
Ex_sum = []

e=0
for i in range(N):
    Ex_sum.append(e)
    e += Ex[i]

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