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:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if K==1:
        print((max(D))/2)
        quit()
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if K==1:
        print((1+max(D))/2)
        quit()
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if N==K:
        print((1+max(D))/2)
        quit()
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if N==K:
        print(D[0]/2)
        quit()
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if N==1:
        print(D[0]/2)
        quit()
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

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

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    
    if K==1:
        print((1+max(P)/2))
        quit()

    for p in P:
        acc += p
        acc_P.append(acc)
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, (K+acc_P[i+K]-acc_P[i])/2)
    ans = max_sum
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    
    if N==1:
        print((1+P[0]/2))
        quit()

    for p in P:
        acc += p
        acc_P.append(acc)
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, (K+acc_P[i+K]-acc_P[i])/2)
    ans = max_sum
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    
    if N==1:
        print((1+P[0]/2))
        quit()

    for p in P:
        acc += p
        acc_P.append(acc)
    print(acc_P)
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, (K+acc_P[i+K]-acc_P[i])/2)
    ans = max_sum
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    
    if N==1:
        print((1+P[0]/2))

    for p in P:
        acc += p
        acc_P.append(acc)
    print(acc_P)
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, (K+acc_P[i+K]-acc_P[i])/2)
    ans = max_sum
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    for p in P:
        acc += p
        acc_P.append(acc)
    
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, (K+acc_P[i+K]-acc_P[i])/2)
    ans = max_sum
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    for p in P:
        acc += p+1
        acc_P.append(acc)
    
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, acc_P[i+K]-acc_P[i])
    ans = (max_sum)/2
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    for p in P:
        acc += p
        acc_P.append(acc)
    
    max_sum = -1
    for i in range(N-K):
        max_sum = max(max_sum, acc_P[i+K]-acc_P[i])
    ans = (max_sum+K)/2
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    for p in P:
        acc += p
        acc_P.append(acc)
    
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, acc_P[i+K]-acc_P[i])
    ans = (max_sum+K)/2
    print('{:.16f}'.format(ans))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    
    P = list(map(int, input().split()))
    acc = 0
    acc_P = []
    for p in P:
        acc += p
        acc_P.append(acc)
    
    max_sum = 0
    for i in range(N-K):
        max_sum = max(max_sum, acc_P[i+K]-acc_P[i])
    ans = (max_sum+K)/2
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

    ans = []
    max_index = p.index(max(p))

    for i in range(max_index-k+1, max_index + 1):
        ans.append(sum(map(ev, p[i: i + k])))
    print(max(ans))\


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * n
for i in range(n):
    p_i = p[i]
    l[i] = p_i * (p_i + 1) // 2 / p_i

now = sum(l[:k])
ans = 0

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

Submission status: Wrong Answer

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

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

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

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

if N == K:
    print(max(l))
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
E = []

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

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

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

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
P2 = [(((P[i]+1)) / 2) for i in range(N)]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P2[i] 

for i in range(1, N-K+1):
    tmp = s - P2[i-1] + P2[i+K-1]
    if s < tmp:
        s = tmp
        init = i

print(s)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
P2 = [(((P[i]+1)) / 2) for i in range(N)]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P2[i] 

for i in range(1, N-K+1):
    tmp = s - P2[i-1] + P2[i+K-1]
    if s < tmp:
        s = tmp
        init = i
result = 0
for i in range(init, init+K):
    result += P2[i]
print(result)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
P2 = [(((P[i]+1)) / 2) for i in range(N)]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P2[i] 
if N == K:
    result = 0
    for i in range(K):
        result += P2[i]
    print(result)
    exit()
for i in range(1, N-K+1):
    tmp = s - P2[i-1] + P2[i+K-1]
    if s < tmp:
        s = tmp
        init = i
result = 0
for i in range(init, init+K):
    result += P2[i]
print(result)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
P2 = [((P[i] * (P[i]+1)) // 2)/P[i] for i in range(N)]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P2[i] 
if N == K:
    result = 0
    for i in range(K):
        result += P2[i]
    print(result)
    exit()
for i in range(1, N-K+1):
    tmp = s - P2[i-1] + P2[i+K-1]
    if s < tmp:
        s = tmp
        init = i
result = 0
for i in range(init, init+K):
    result += P2[i]
print(result)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P[i] 
if N == K:
    result = 0
    for i in range(K):
        result += ((P[i] * (P[i]+1)) // 2)/P[i]
    print(result)
    exit()
for i in range(1, N-K+1):
    tmp = s - P[i-1] + P[i+K-1]
    if s < tmp:
        s = tmp
        init = i
result = 0
for i in range(init, init+K):
    result += ((P[i] * (P[i]+1)) // 2)/P[i]
print(result)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P[i] 
if N == K:
    result = 0
    for i in range(K):
        result += ((P[i] * (P[i]+1)) // 2)/P[i]
    print(result)
    exit()
for i in range(1, N-K):
    tmp = s - P[i-1] + P[i+K-1]
    if s < tmp:
        s = tmp
        init = i
result = 0
for i in range(init, init+K):
    result += ((P[i] * (P[i]+1)) // 2)/P[i]
print(result)

Submission status: Wrong Answer

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

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

ms=0
for i in range(len(P)-k):
    s +=(P[i+k]-P[i])
    if s>ms :
        ms=s

print((ms+k)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for i in range(n):
  ev.append(Decimal((p[i] * (p[i] + 1) / 2) / p[i]))
m = Decimal(sum(ev[:k]))
ans = 0
for i in range(k, n):
  ans = max(m, Decimal(m - ev[i - k] + ev[i]))
  m = Decimal(m - ev[i - k] + ev[i])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
M=[0]
c=0
m=0
x=0
for i in range(200100):
    c+=i
    L.append(c)
for i in P:
    m+=L[i]/i
    M.append(m)
if N!=K:
    for i in range(N-K):
        x=max(M[K+i]-M[i],x)
else:
    x=M[K]-M[0]
print(x)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
M=[]
c=0
m=0
x=0
for i in range(200100):
    c+=i
    L.append(c)
for i in P:
    m+=L[i]/i
    M.append(m)
for i in range(N-K):
    x=max(M[K+i]-M[i],x)
print(x)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
M=[]
c=0
m=0
x=0
for i in range(200001):
    c+=i
    L.append(c)
for i in P:
    m+=L[i]/i
    M.append(m)
for i in range(N-K):
    x=max(M[K+i]-M[i],x)
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

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

exlis = []

for i in lis:
    a = (1+i)/2
    exlis.append(a)

nlis = list(itertools.accumulate(exlis))

ans  = 0
for j in range(n-k):
    tmp = nlis[j+k] - nlis[j]
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

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

if N == 1 or N-K == 0:
    print(l[0])
else:
    print(ans)

Submission status: Wrong Answer

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

if N == 1 or K-N == 0:
    print(l[0])
else:
    print(ans,a,l)

Submission status: Wrong Answer

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

if N == 1:
    print(l[0])
else:
    print(ans)

Submission status: Wrong Answer

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

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
a[0] = l[0]
for i in range(1,len(l)):
    a[i] = a[i-1] + l[i]

x = a.index(max(a))
print(max(a) - a[x-K],a,l)

Submission status: Wrong Answer

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

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

k = []
for i in range(len(l)):
    k.append(sum(l[i:i+K]))

print(max(k),l)

Submission status: Wrong Answer

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

q=[]

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

ans=sum(q[:k])

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

Submission status: Wrong Answer

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

q=p[:k]

ans=0

for i in q:
  ans+=i
  
ans/=2

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    prev_K_sum = max_K_sum = sum(P[:K])
    start = 0
    for i in range(N-K):
        cur_K_sum = prev_K_sum - P[i] + P[i+K]
        if cur_K_sum > max_K_sum:
            start = i + 1
        prev_K_sum = cur_K_sum
    target = P[start:start+K]
    ans = sum([(num+1)/2.0 for num in target])
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    prev_K_sum = max_K_sum = sum(P[:K])
    start = 0
    for i in range(N-K):
        cur_K_sum = prev_K_sum - P[i] + P[i+K]
        if cur_K_sum > max_K_sum:
            start = i + 1
        prev_K_sum = cur_K_sum
    target = P[start:start+K]
    ans = sum([(num+1)/2.0 for num in target])
    print(ans, target)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    prev_K_sum = max_K_sum = sum(P[:K])
    start = 0
    for i in range(N-K):
        cur_K_sum = prev_K_sum - P[i] + P[K]
        if cur_K_sum > max_K_sum:
            start = i + 1
        prev_K_sum = cur_K_sum
    target = P[start:start+K]
    ans = sum([(num+1)/2.0 for num in target])
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

pos = 0
m = sum(P[0:K])
for i in range(1,N):
    if i+K > N:
        break
    n = m - P[i-1] + P[K-1+i]
    if n > m:
        pos = i
        m = n

print((sum(P[pos:pos+K]) + K) / 2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
maxi=0
for i in range(n-k):
    if l[k+i]>l[i]:
        maxi=i+1
sumsum=0
for j in range(maxi,maxi+k):
    sumsum+=(l[j]+1)/2
print(sumsum)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
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)
    
maxindex = 0
pre = sum(P[:k])
for i in range(1,n-k+1):
    now = pre - P[i - 1] + P[i + k - 1] 
    if now > pre:
        maxindex = i
        pre = now

ans = 0
for i in range(maxindex,maxindex + k):
    ans += ave[i]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
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)

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

print(ans)

Submission status: Wrong Answer

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)  
    if n == k:
        print(p_e[0])
    else:
        # 初期値
        maxv = p_e[k-1] - 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: Wrong Answer

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)  
    if n == k:
        print(p_e)
    else:
        # 初期値
        maxv = p_e[k-1] - 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: Wrong Answer

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

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)  
    print(p_e)
    # 初期値
    maxv = p_e[k-1] - 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: Wrong Answer

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 = 0
    for i in range(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: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate
input = sys.stdin.readline

n,k=map(int,input().split())
L=list(map(int,input().split()))
M=[]
for i in L:
    M.append((1+i)/2)

N=list(accumulate(M))
MAX = -1
j = 0
for i in range(k,n):
    val = N[i]-N[j]
    j+=1
    MAX = max(MAX,val)
print("%.12f"%MAX)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, k, *p = map(int, open(0).read().split())
ans = float()
c = (sum(p[:k]) + k) / 2


def e(x):
    return (x + 1) / 2


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

Submission status: Wrong Answer

Solution code:
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]/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)

Submission status: Wrong Answer

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

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

print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
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))

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

print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
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()
    # print(E_half)
    print(Pcum)
    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]

    # partial_sums = Pcum[K:] - Pcum[0:-K]
    return (partial_sums_E_half.max())/2
print(main())

Submission status: Wrong Answer

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

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

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 )