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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = -1

for i in range(N):
    res = p[i]

print(res)

Submission status: Wrong Answer

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

dp = [0] * (n + 1)

for i in range(n):
    dp[i+1] = dp[i] + (pl[i] + 1)

ans = 0
for i in range(n-k):
    pmax = dp[i+k+1] - dp[i+1]
    if pmax >= ans:
        ans = pmax

print(ans/2)

Submission status: Wrong Answer

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

dp = [0] * (n + 1)

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

ans = 0
for i in range(n-k):
    pmax = dp[i+k+1] - dp[i+1]
    if pmax >= ans:
        ans = pmax

print(ans)

Submission status: Wrong Answer

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

dp = [0] * (n + 1)

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

ans = 0
for i in range(n-k):
    pmax = dp[i+k+1] - dp[i+1]
    if pmax > ans:
        ans = pmax

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
dp = [0] * n

dp[0] = (pl[0] + 1) / 2

for i in range(1, n):
    dp[i] = dp[i-1] + (pl[i] + 1)/2

pmax = [0] * (n-k+1)

for i in range(n-k):
    pmax[i] = dp[i+k] - dp[i]

print(max(pmax))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
# dp = [0] * n
# dp[0] = (pl[0] + 1) / 2
#
# for i in range(1, n):
#     dp[i] = dp[i-1] + (pl[i] + 1)/2
#
# pmax = 0
# for i in range(n-k):
#     psum = dp[i+k] - dp[i]
#     if pmax < psum:
#         pmax = psum

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

pmax = 0

for i in range(n-k):
    psum = sum(dp[i:i+k])
    if pmax < psum:
        pmax = psum

print(pmax)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
dp = [0] * (n + 1)
# dp[0] = (pl[0] + 1) / 2

for i in range(1, n+1):
    dp[i] = dp[i-1] + (pl[i-1] + 1)/2

pmax = 0
for i in range(1, n-k+1):
    psum = dp[i+k] - dp[i]
    if pmax < psum:
        pmax = psum

print(pmax)
print(dp)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
dp = [0] * n
dp[0] = (pl[0] + 1) / 2

if n != 1:
    for i in range(1, n):
        dp[i] = dp[i-1] + (pl[i] + 1)/2

pmax = 0
for i in range(n-k):
    psum = dp[i+k] - dp[i]
    if pmax < psum:
        pmax = psum

print(pmax)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
dp = [0] * n
dp[0] = (pl[0] + 1) / 2

for i in range(1, n):
    dp[i] = dp[i-1] + (pl[i] + 1)/2

pmax = 0
for i in range(n-k):
    psum = dp[i+k] - dp[i]
    if pmax < psum:
        pmax = psum

print(pmax)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
S=sum(P[-K:])
ans=(K+S)/2
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
S=sum(P[:-K])
ans=(K+S)/2
print(ans)

Submission status: Wrong Answer

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

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

def kitaiti(num):
    result = (num+1)*num/(num*2)
    return result
r = [kitaiti(p[i]) for i in range(n)]

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

Submission status: Wrong Answer

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]

#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]
p+=[0]

ans = 0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import decimal

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]

#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]

ans = 0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print(decimal.Decimal(ans))

Submission status: Wrong Answer

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]
#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]

ans = 0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print(ans)

Submission status: Wrong Answer

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]
print(p)
#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]
print(p)

ans = 0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print(ans)

Submission status: Wrong Answer

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]

#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]

ans = .0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print("{:.6g}".format(ans))

Submission status: Wrong Answer

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]

#累積和
for i in range(1,len(p)):
    p[i]+=p[i - 1]

ans = 0
for i in range(len(p) - k):
    ans = max(ans,p[i + k] - p[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = list(map(int,input().split()))
n = N[0]
k = N[1]

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

i=0
E = []
#期待値のリスト
for e in X:
  E.append((1+e)/2)
  i += 1

j = 0
T=[]
T.append(0)
#期待値の累積和
for t in E:
  T.append(T[j] + t)
  j += 1

max_val = 0
max_st = 0
for i in range(0,j-k):
  tmp_val = T[i+k] - T[i]
  if tmp_val >= max_val :
    max_st = i
    max_val = tmp_val


print(max_val)

Submission status: Wrong Answer

Solution code:
N = list(map(int,input().split()))
n = N[0]
k = N[1]

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

#----
#max_val = 0
#max_st = 0
#for i in range(0,n-k):
#  tmp_val = X[i] + X[i+1] + X[i+2]
#  if tmp_val >= max_val :
#    max_st = i
#    max_val = tmp_val

#max_p = (1+X[i])/2 + (1+X[i+1])/2 + (1+X[i+2])/2
#print(max_p)
#---

X.sort()
max_p = 0
for i in range(1,k+1):
  max_p += (1+X[n-i])/2
  
print(max_p)

Submission status: Wrong Answer

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

exp = []
sum_list = [0]
result_list = []
result = 0
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    tmp = sum_list[K+i] - sum_list[i]
    if result < tmp:
        result = tmp
    
print(tmp)

Submission status: Wrong Answer

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

exp = []
for i in range(N):
    exp.append((p[i]+1)/(2))    
print(exp)
sum_list = []
for i in range(N-K+1):
    sum_list.append(sum(exp[i:K+i]))
print(max(sum_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = []
for i in range(N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(SUM/p)
print(E)
l = 0
r = K - 1
ans = 0
while r < N:
    ans = max(ans, sum(E[l:r+1]))
    l += 1
    r += 1
print(ans)

Submission status: Wrong Answer

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

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

    P_sum = []
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

s = 0
a = sum(p[:k])
for i in range(n-k):
    if a > s:
        s = a
    a = a-p[i]+p[i+k]
        
print((s+k)/2)

Submission status: Wrong Answer

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

prev = 0.0
for i in range(K):
    prev += p[i] + 1
prev = prev/2.0

ans = prev
for i in range(N-K):
    now = prev + (p[i+K] - p[i])/2
    if now > prev:
        ans = now
    prev = now
print(ans)

Submission status: Wrong Answer

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

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

ans = prev
for i in range(N-K):
    now = prev + (p[i+K] - p[i])/2
    if now > prev:
        ans = now
    prev = now
print(ans)

Submission status: Wrong Answer

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

def cul(a):
    sum = 0
    for i in range (1,a+1):
        sum += i
    sum = sum/a
    return sum

prev = 0
for j in range(K):
    prev += cul(p[j])
ans = 0

for i in range(N-K):
    ans = prev - cul(p[i]) +cul(p[i+K])
    if prev > ans:
        ans = prev
    prev = ans
print(ans)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
expected.append(i)
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(n-k+1):
    if(n == k):
        answer = expected[1]
        break
    sumOfValue = expected[maxvalue+k] - expected[maxvalue]
    if(answer <= sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
expected.append(0)
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(n-k):
    if(n == k):
        answer = expected[1]
        break
    sumOfValue = expected[maxvalue+k+1] - expected[maxvalue+1]
    if(answer <= sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(len(expected)-k):
    if(n == k):
        answer = expected[0]
        break
    sumOfValue = expected[maxvalue+k] - expected[maxvalue]
    if(answer <= sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(len(expected)-k):
    if(n == k):
        answer = expected[0]
        break
    sumOfValue = expected[maxvalue+k] - expected[maxvalue]
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(len(expected)-k):
    sumOfValue = expected[maxvalue+k-1] - expected[maxvalue-1]
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
cumulative_sum = []
answer = 0
i = 0
j = 0
sumOfValue = 0
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for maxvalue in range(len(expected)-k):
    sumOfValue = expected[maxvalue+k] - expected[maxvalue]
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0.0
for i in range(K-1,N):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
print(R)
ans=0.0
for i in range(K-1,N):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K-1,N):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K,N):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
#面の数から期待値に変換してからforぶん回して無理やり最大値を求める
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
sumOfValue = 0
#サイコロの目を期待値に変換
for eyes in dices:
    expected.append((eyes+1)/2)
#最大値を求める
print(len(expected)-k)
for maxvalue in range(len(expected)-k+1):
    sumOfValue = sum(expected[maxvalue:maxvalue+k])
    if(answer < sumOfValue):
        answer = sumOfValue
print(answer)

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
s = []
for i in range(n-k+1):
    s += [p[i:i+k]]

print((sum(max(s))+k)/2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = [0.5*(i+1) for i in p]
kitasum = []
for i in range(n):
    if i != 0:
        kitasum.append(kita[i]+kitasum[-1])
    else:
        kitasum.append(kita[i])
maxn = 0
for i in range(n):
    kt = kitasum[i] - kitasum[i-k]
    if kt > maxn:
        maxn = kt
print(maxn)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = map(int,input().split())
l = list(map(int, input().split()))
l_a = sorted(l, reverse=True)[0:K]
np_l = np.array(l_a)
ans= np.sum((np_l + 1) / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([i + 1 for i in p])
ans = np.sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    diff = ex[i] - ex[i - K]
    ans += diff
    if diff > 0:
        max_ans = ans
print(max_ans / 2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([(i + 1) / 2 for i in p])
ans = np.sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    diff = ex[i] - ex[i - K]
    ans += diff
    if diff > 0:
        max_ans = ans
print(max_ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([(i + 1) / 2 for i in p])
ans = np.sum(ex[0: 3])
max_ans = ans
for i in range(3, N):
    diff = ex[i] - ex[i - 3]
    ans += diff
    if diff > 0:
        max_ans = ans
print(max_ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = 0
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
ex = float(max+k)/2.000000000000
print(ex)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = 0
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
ex = float(max+k)/2.0
print('{:.12f}'.format(ex))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = 0
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
print(float(max+k)/2.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]
s = sum(p[0:k])
max = 0
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if max < s:
    max = s
    
print((max+k)/2.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

s = sum(p[0:k+1])
max = s
for i in range(n-k):
  s = s - p[i] + p[k+i]
  if max < s:
    max = s
    
print((max+k)/2.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

s = sum(p[0:k+1])
max = s
for i in range(n-k):
  s = s - p[i] + p[k-i]
  if max < s:
    max = s
    
print((max+k)/2.0)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ans = 0
total = 0
for i in range(N - K + 1):
    total = 0
    c_1 = 1
    c_2 = np.prod(p[i: i + K])
    for k in range(i, i + K):
        c_2 /= p[k]
        total += (p[k] * (p[k] + 1) / 2) * c_1 * c_2
        c_1 *= p[k]
    ans = max(total / c_1, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for _ in range(k):
    s += p[j]
    j += 1
  if max < s:
    max = s
    
print((max+k)/1.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for j in range(k):
    s += p[j]
    j += 1
  if max < s:
    max = s
  i += 1
    
print((max+k)/1.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for j in range(k):
    s += p[j]
    j += 1
  if max < s:
    max = s
    
print((max+k)/1.0)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = [int(e) for e in input().split()]

e = [(q+1.0)/2 for q in p]

max = 0
for i in range(n-k+1):
  j = i
  s = 0
  for j in range(k):
    s += e[j]
    j += 1
  if max < s:
    max = s
    
print(max)

Submission status: Wrong Answer

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

S = [(1+P[0])/2]
for i, p in enumerate(P[1:]):
  # print(i, p, S)
  S.append(S[i] + (1+p)/2)
# print(S)
s_max = -1
for j in range(n-k):
  tmp = S[j+k] - S[j]
  if s_max < tmp:
      s_max = tmp
print(s_max)

Submission status: Wrong Answer

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

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

ans = 0
cumlative = []
for i in range(N):
	if i == 0:
		cumlative.append(ave[i])
	else:
		cumlative.append(cumlative[i-1]+ave[i])
	#print(ave[i:K+i])

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

print(ans)

Submission status: Wrong Answer

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


m=0
ml=[]
if(K!=1):
    for i in range(N-K+1):
        tmp=0
        tmpl=[]
        for j in range(i,K+i):
            tmp+=p[j]
            tmpl.append(p[j])
        print(m,ml,tmp,tmpl)
        if(tmp > m):
            m=tmp
            ml=tmpl
else:
    ml=[max(p)]
kitai=0
for pi in ml:
    for i in range(1,pi+1):
        kitai+=i/pi

print(kitai)

Submission status: Wrong Answer

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


m=0
ml=[]
if(K!=1):
    for i in range(N-K):
        tmp=0
        tmpl=[]
        for j in range(i,K+i):
            tmp+=p[j]
            tmpl.append(p[j])
        if(tmp > m):
            m=tmp
            ml=tmpl
else:
    ml=[max(p)]
kitai=0
for pi in ml:
    for i in range(1,pi+1):
        kitai+=i/pi

print(kitai)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = map(int, input().split())
tmp_p = list(map(int, input().split()))
expect_value = np.zeros(N+1)

expect_value[0] = 0
for i in range(1, N):
    expect_value[i] = expect_value[i-1] + tmp_p[i]

max_value = 0
for i in range(N-K+1):
    tmp_value = expect_value[i+K] - expect_value[i]
    if max_value < tmp_value:
        max_value = tmp_value

print((max_value+K)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

INDEX = -1
MA = 0
for i in range((N - K + 1)//2):
    M = 0
    L = 0
    for j in range(K):
        M += P[i + j]
        L += P[-1-i-j]
    print(L)
    if M > MA:
        MA = M
        INDEX = i
    if L > MA:
        MA = L
        INDEX = N-K-i

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

print("{:.12f}".format(ans))

Submission status: Wrong Answer

Solution code:
# ABC154 D

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

sumP = []

for i in range(1, n-k+2):
    sumP.append(sum(P[i:i+k]))

print((max(sumP) + k) / 2)

Submission status: Wrong Answer

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

for p in input_list:
    x = 0
    y = 0
    for i in range(0,int(p)+1):
        x = x + i
    y = x / int(p)
    average_list.append(y)

avg_list = sorted(average_list, reverse=True)
print(avg_list)
answer = 0
for i in range(int(k)):
    answer = answer + avg_list[i]
print(answer)

Submission status: Wrong Answer

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

P.sort(reverse=True)
ans = 0
for i in range(K):
    tmp = P[i] * (P[i] + 1) / 2
    # print(tmp/P[i])
    ans += tmp/P[i]
# print(P)
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = [0] + list(accumulate(evs))
ans = 0
for i in range(1, N-K+1):
    ans = max(ans, evs[i+K]-evs[i])
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = list(accumulate(evs))
ans = 0
for i in range(N-K):
    ans = max(ans, evs[i+K]-evs[i])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
e = [0.0] * n
for i in range(n):
    e[i] = (1 + p[i]) * 0.5
s = 0.0
for i in range(k, n):
    s = max(s, sum(e[i - k:i]))
print(s)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
#さいころの出目の和を集計
for i in range(n):
    p[i]+=1

sdict={}
sdict[0]=p[0]

for i in range(n-1):
	sdict[i+1]=sdict[i]+p[i+1]
j=0
ans=0
while (j+k <=n):
	if j+k==n:
		ans=sum(p)
		break
	dif=sdict[j+k]-sdict[j]
	ans=max(dif,ans)
	j+=1
print(ans/2)

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split(" ")))
p = list(map(int, input().split(" ")))
p2=[0.]*(N[0]-N[1]+1)
for i in range(N[0]-N[1]+1):
    p2[i]=sum(p[i:(i+N[1])])

print(max(p2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 自分の
N, K = map(int, input().split())
p_arr = list(map(int, input().split()))

# 最高値を算出
max_sum = 0
for i in range(N-K+1):
    if sum(p_arr[i:i+K])>max_sum:
        max_sum = sum(p_arr[i:K])

answer = (max_sum + K) / 2
print(answer)

Submission status: Wrong Answer

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

def calculate_Expectation(n):
    n = int(n)
    p = 1/n
    e = p * (n*(n+1)/2)
    return e

E = list(map(calculate_Expectation, input().split()))
if N == K:
    print(E[0])
else:
    S = [0]
    for i, e in enumerate(E):
        S.append(S[i]+e)

    sum_of_E = []
    for left in range(N-K):
        right = left + K
        sum_of_E.append(S[right]-S[left])
    print(max(sum_of_E))

Submission status: Wrong Answer

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

def calculate_Expectation(n):
    n = int(n)
    p = 1/n
    e = p * (n*(n+1)/2)
    return e

E = list(map(calculate_Expectation, input().split()))
if N == K:
    print(E[0])
else:
    S = [0]
    for i, e in enumerate(E):
        S.append(S[i]+e)

    sum_of_E = []
    for left in range(1, N+1-K):
        right = left + K
        sum_of_E.append(S[right]-S[left])
    print(max(sum_of_E))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
a=0
for j in range(K):
    a+=(1+p[j])/2
Max=a
for i in range(K-1,N):
    a=a+(p[i]-p[i-K+1])/2
    if Max<a:
        Max=a
print(Max)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
#さいころの出目の和を集計
for i in range(n):
    p[i]+=1

sdict={}
sdict[0]=p[0]

for i in range(n-1):
	sdict[i+1]=sdict[i]+p[i+1]
j=0
ans=0
while (j+k <n):
	dif=sdict[j+k]-sdict[j]
	ans=max(dif,ans)
	j+=1
print(ans//2)