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

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

S=[0]*N
for i in range(N):
    S[i]=sum(E[:i])

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

print(max(A))

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp//contests/abc154/tasks/abc154_d"

def search_ind(lis, k):
    val = sum(lis[0:k])
    inds = [0, k - 1]
    for i in range(0, len(lis) - k):
        tmp = val - lis[i] + lis[i + k]
        # print(tmp, lis[i + k])
        if tmp > val:
            inds = [i + 1, i + k]
        val = tmp
    return inds

def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    f, t = search_ind(daice, k)
    kitai = daice[f:t + 1]
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc154/tasks/abc154_d"

def search_ind(lis, k):
    val = sum(lis[0:k])
    inds = [0, k - 1]
    for i in range(0, len(lis) - k):
        tmp = val - lis[i] + lis[i + k]
        # print(tmp, lis[i + k])
        if tmp > val:
            inds = [i + 1, i + k]
        val = tmp
    return inds

def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    f, t = search_ind(daice, k)
    kitai = daice[f:t + 1]
    print(f, t, kitai)
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def search_ind(lis, k):
    val = sum(lis[0:k])
    inds = [0, k - 1]
    for i in range(0, len(lis) - k + 1):
        tmp = val - lis[i] + lis[i + k - 1]
        if tmp > val:
            val = tmp
            inds = [i, i + k - 1]
    return inds

def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    sum_val = 0
    kitai = []
    f, t = search_ind(daice, k)
    kitai = daice[f:t + 1]
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
E=lambda x:(x+1)/2
p=list(map(int,input().split()))
P=[E(n) for n in p]
print(P)
M=0
for i in range(N-K+1):
    m=sum(P[i:i+K])
    M=max(M,m)
print(M)

Submission status: Wrong Answer

Solution code:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-1]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = list(map(int, input().split()))
P = np.array(list(map(int, input().split())))
E = (P+1)/2.0

r = K
l = r - K
argmaxl = l
argmaxr = r
maxE = 0
while r <= N:
    e = np.sum(E[l:r])
    if maxE < e:
        maxE = e
        argmaxl = l
        argmaxr = r
    if r == N:
        break
    l = r
    r += K
    if r > N:
        r = N

if l < K:
    l = 0
else:
    l = argmaxl - K + 1
r = l + K

maxE = 0
for i in range(l, argmaxr+K):
    e = np.sum(E[i:i+K])
    if maxE < e:
        maxE = e

print(maxE)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
l=[]
for i in p:
  l.append(i+1)
t=np.cumsum(np.array(l),dtype=int)
for j in range(n-k):
  ans=max(ans,t[j+k]-t[j])
print(ans/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]
std=0
index=0
memo=0
for i in range(n-k+1):
  c = p[i+k-1] - p[i]
  memo += c
  if std < memo:
    std = memo
    index = i
b=p[index : index + k]
ans=sum(b)
print(ans)

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]
std=0
index=0
memo=0
for i in range(1,n-k+1):
  c = p[i+k-1] - p[i]
  memo += c
  if std < memo:
    std = memo
    index = i
b=p[index : index + k]
ans=sum(b)
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort(reverse = True)
ans = 0
for i in range(k):
    ans += (p[i] + 1) / 2
print('{:.12f}'.format(ans))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
std=0
index=0
memo=0
for i in range(1,n-k+1):
  c = p[i+k-1] - p[i]
  memo += c
  if std < memo:
    std = memo
    index = i
b=p[index : index + k]
ans=sum(b)/2+k/2
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

mx = 0
cs = 0
for i in range(k):
    cs += pL[i]
    mx = cs
for i in range(1, len(pL) - k + 1):
    cs = cs - pL[i - 1] + pL[i + k - 1]
    print(cs)
    mx = max(mx, cs)
print((mx + k) / 2)

Submission status: Wrong Answer

Solution code:
# input
N, K = map( int, input().split() )
P    = [int(x) for x in input().split()]

# calc cumsum
C    = list()
cumsum = 0
for ii in range( len(P) ):
    E = (1+P[ii])/2
    C.append( cumsum + E )
    cumsum += E

ans = 0
for ii in range( K, N ):
    E = C[ii] - C[ii-K]
    if( ans < E ):
        ans = E

# output        
print( ans )

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_cum = [0] * N
P_cum[0] = P[0]
for i in range(1, len(P)):
    P_cum[i] = P_cum[i - 1] + P[i]

me = 0
for i in range(N - K + 1):
    if i >= 1:
        e = (P_cum[i + K - 1] - P_cum[i - 1] + K) / 2
    else:
        e = (P_cum[i] + K) / 2
    me = max(e, me)

print(me)

Submission status: Wrong Answer

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

sc=list(map(int,input().split()))
c=[]
t=[]

for i in range(n):
  c.append((1+sc[i])/2)
t.append(c[i])
for i in range(1,n):
  t.append(c[i]+t[i-1])
total = 0
for i in range(n-k):
  if total < t[i+k] - t[i]:
    total = t[i+k] - t[i]
print(total)

Submission status: Wrong Answer

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

st_idx  = 0
max_sum = 0
for nn in range( K ):
    max_sum += P[nn]

tmp = max_sum
for nn in range( K, len(P) ):
    tmp -= P[nn-K]
    tmp += P[nn]
    if( tmp > max_sum ):
        st_idx = nn-K+1
    
ans = 0
for nn in range( st_idx, st_idx+K ):
    tmp = ( 1 + P[nn] ) / 2
    ans += tmp
        
print( ans )

Submission status: Wrong Answer

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

st_idx  = 0
max_sum = 0
for nn in range( K ):
    max_sum += P[nn]

tmp = max_sum
for nn in range( K, len(P) ):
    tmp -= P[nn-K]
    tmp += P[nn]
    if( tmp > max_sum ):
        st_idx = nn-K+1
    
ans = 0
for nn in range( st_idx, st_idx+K ):
    tmp = 1 + 0.5*( P[nn]-1 )
    ans += tmp
        
print( ans )

Submission status: Wrong Answer

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

sc=list(map(int,input().split()))
c=[]

for i in range(n):
  c.append((1+sc[i])/2)
total = 0
totalmax = 0
for i in range(n-k):
  for j in range(k):
    total += c[j+i]
  if total > totalmax:
    totalmax = total
  total = 0
print(totalmax)

Submission status: Wrong Answer

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

# N = 10
# K = 4
# PRR = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]

# N = 5
# K = 3
# PRR = [1, 2, 2, 4, 5]

def calculate(n, k, prr):

    sumarr = []
    for i in range(n):
        if len(sumarr) == 0:
            sumarr.append(prr[0])
        else:
            sumarr.append(sumarr[-1] + prr[i])


    maxSum = []


    for i in range(k-1,n):
        sss = sumarr[i] - sumarr[i-k]
        maxSum.append(sss)

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


calculate(N, K, PRR)

Submission status: Wrong Answer

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

# N = 10
# K = 4
# PRR = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]

# N = 5
# K = 3
# PRR = [1, 2, 2, 4, 5]

def calculate(n, k, prr):

    sumarr = []
    for i in range(n):
        if len(sumarr) == 0:
            sumarr.append(prr[0])
        else:
            sumarr.append(sumarr[-1] + prr[i])
    maxSum = 0
    for i in range(k-1,n):
        sss = sumarr[i] - sumarr[i-k]
        if sss > maxSum:
            maxSum = sss

    print((k+maxSum)/2)
calculate(N, K, PRR)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

s_list = [0]*(n+1)
s_list[1] = p[0]
for i in range(1, n+1):
    s_list[i] = p[i-1] + s_list[i-1]

for i in range(1, n-k+1):
    e = (s_list[i+k] - s_list[i] + k)/2
    if ans < e:
        ans = e
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
list_p = []
for i in range(n-k+1):
    list_p.append(p[i:i+k])

for i in range(n-k-1):
    e = (sum(list_p[i]) + k) / 2
    if ans < e:
        ans = e

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())))
ans = 0
tmp = np.sum((p[0:K]+1)/2)

for n in range(1, N-K+1):
	last = (p[n-1]+1)/2
	next = (p[n+K-1]+1)/2
	tmp = tmp - last + next
	if ans < tmp:
		ans = tmp

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())))
ans = 0
tmp = np.sum((p[0:K]+1)/2)
last = p[0]

for n in range(1, N-K):
	tmp = tmp - last + p[n+K-1]
	if n != N - K:
		last = p[n+1]
	if ans < tmp:
		ans = tmp

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())))
ans = 0
tmp = np.sum((p[0:K]+1)/2)
last = p[0]

for n in range(1, N-K):
	tmp = tmp - last + p[n+K-1]
	if n != N - K:
		last = p[n]
	if ans < tmp:
		ans = tmp

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())))
ans = 0
tmp = np.sum((p[0:K]+1)/2)
last = p[0]

for n in range(1, N-K+1):
	tmp = tmp - last + p[n+K-1]
	if n != N - K:
		last = p[n+1]
	if ans < tmp:
		ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
def exp(x):
    exp=1/2*(x+1)
    return exp

n,k=map(int,input().split())
p=list(map(int, input().split()))
sum_list=[]
syokiti=0
for i in range(k):
    syokiti+=exp(p[i])
sum_list.append(syokiti)
for i in range(1,n-k+1):
    sum_list.append(sum_list[i-1]+p[i+k-1]-p[i])
    sum_list.append(syokiti)

print(max(sum_list))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
summation=[A[0]]
for i in range(1,N):
  summation.append(summation[i-1]+A[i])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

meanList = []

for a in p:
    meanList.append((a + 1) / 2)

sums = [0]

for a in meanList:
    sums.append(sums[-1] + a)

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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

maxDice = 0
maxi = 0
maxl = 0
for i in range(k):
    maxi += p[i]

maxDice = maxi

for i in range(n-k):
    maxi -= p[i]
    maxi += p[k+i]
    if (maxDice <= maxi):
        maxDice = max(maxDice, maxi)
        maxl += 1

ans = 0

for i in range(k):
    ans += allMean(p[maxl + i])

print(ans)

Submission status: Wrong Answer

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

def allSum(x):
    return x*(x+1) // 2

maxDice = 0
maxi = 0
maxl = 0
for i in range(k):
    maxi += p[i]

maxDice = maxi

for i in range(n-k):
    maxi -= p[i]
    maxi += p[k+i]
    if (maxDice <= maxi):
        maxDice = max(maxDice, maxi)
        maxl += 1

ans = 0

for i in range(k):
    ans += allSum(p[maxl + i]) / p[maxl + i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
A=[0]*N #期待値の累積和を入れる
A[0]=(p[0]+1)/2
for i in range(1,N):
  A[i]=A[i-1]+(p[i]+1)/2
#隣接するK個のさいころの期待値の和をすべて求める
B=[]
for j in range(N-K+1):
  s=A[j+K-1]-A[j]
  B.append(s)
print(max(B))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
A=[0]*N #期待値の累積和を入れる
A[0]=(p[0]+1)/2
for i in range(1,N):
  A[i]=A[i-1]+(p[i]+1)/2
B=[]
for j in range(N-K+1):
  s=A[j:j+K]
  B.append(s)
print(max(B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p,reverse=True)
s=0
for i in range(K):
  s+=(1+p[i])/2
print(s)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
*p, = map(int, input().split())
Ep = [(x + 1) / 2 for x in p]
sums = [0 for _ in range(N - K + 1)]
sums[0] = sum(Ep[:K])
for i in range(N-K):
  sums[i+1] = sums[i]+Ep[i+K]-Ep[i]
print(sums)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
def P(x):
    return (x+1)/2
a=0
y=0
for i in range(N-K):
    y+=P(p[i])#区間内の期待値の和
    if i>=K:
        y-=P(p[i-K])
    if a<y:
        a=y
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
p=list(map(int,input().split()))
E=[]
for i in range(N):
  E.append((1+p[i])/2)
S=np.cumsum(E)
max=0
for i in range(N-K+1):
  if S[i+K-1]-S[i-1]>max:
    max=S[i+K-1]-S[i-1]
print(max)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(float, input().split()))
tmp = sum(p[:k])
ans = 0

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

print((ans + k) / 2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
ans = 0

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

print((ans + k) / 2)

Submission status: Wrong Answer

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

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

ans_l = max(ans_l)

for j in ans_l:
    ans += (j+1) / 2

print(ans)

Submission status: Wrong Answer

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

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

for j in ans_l:
    ans += (j+1) / 2

print(ans)

Submission status: Wrong Answer

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

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

for j in ans_l:
    ans += sum(range(j+1)) / j
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC154 -virtual
# A
if False:
    S,T=input().split()
    A,B=map(int,input().split())
    U=input()
    if U==S:
        A-=1
    else:
        B-=1
    print(A,B)
# B
if False: print('x'*len(input()))
# C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    print('YES' if len(A)==len(set(A)) else 'NO')
# D
if True:
    N,K=map(int,input().split())
    P=[int(i) for i in input().split()]
    E=[(p+1)/2 for p in P]
    # print(E)
    ans=0
    tmp=sum(E[0:K])
    l,r=1,K
    while r<len(E):
        # print(l,r)
        tmp=tmp-E[l-1]+E[r]
        ans=max(ans,tmp)
        # print(ans)
        l+=1
        r+=1
    print(ans)
        
# E
# F

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
hope = []
for i in range(N):
  hope.append((P[i]+1)/2)
hope = list(accumulate(hope))

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from decimal import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
hope = []
for i in range(N):
  hope.append(Decimal((P[i]+1)/2))
hope = list(accumulate(hope))

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

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

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)


Max = -100000
for i in range(n-k):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

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

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)

print(sumlist)

Max = -100000
for i in range(n-k):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Submission status: Wrong Answer

Solution code:
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append((a[i]+1)/2)
mx=0
for i in range(n-k):
    y=sum(b[i:i+k])
    if(y>mx):
        mx=y
print(mx)

Submission status: Wrong Answer

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

S = []
ahi = 0.
ans = 0.
for i, n in enumerate(ps):
    ahi += (n + 1.) / 2.
    S.append(ahi)

    if i >= K:
        ans = max(ans, S[i] - S[i-K])
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

max = 0
for i in range(n-k):
    if(max < rsum[i+k] - rsum[i]):
        max = rsum[i+k] - rsum[i]
print(max)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,k = l_in()
P = list(map(lambda p: (1+p)/2, l_in()))
print(P)

res = sum(P[:k])
current = res

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

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate



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


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    for i in range(n):
        p[i] = expectation(p[i])
    p = list(accumulate(p))
    answer = 0
    for i in range(n - k + 1):
        answer = max(answer, p[i + k - 1] - p[i - 1])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

result = 0
tmp = sum(P[0:K])

for i in range(1, N-K+1):
    tmp += (P[i+K-1] - P[i-1])
    if (tmp > result):
        result = tmp

print((result+K)/2)

Submission status: Wrong Answer

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

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

result = 0
for i in range(0, N-K+1):
    tmp = P[i]
    # tmp = sum(P[i:i+K])
    if (tmp > result):
        result = tmp

print((result+K)/2)

Submission status: Wrong Answer

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

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

result = 0
# for i in range(0, N-K+1):
#     tmp = sum(P[i:i+K])
#     if (tmp > result):
#         result = tmp

print((result+K)/2)

Submission status: Wrong Answer

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

excepted = [(v*(v+1) / 2) / v for v in p]

left = 0
right = 0

ans = 0
tmp = 0

while left != n - 1:
    if tmp > ans:
        ans = tmp
    if right - left < k and right != n - 1:
        tmp += excepted[right]
        right += 1
    else:
        tmp -= excepted[left]
        left += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [sum(range(1, p+1))/p for p in P]

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(1, N+1-K):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P = list(map(int, input().split()))
L = []
for i in P:
    if i % 2 == 0:
        L.append((i+1)*(i//2)*(1/i))
    else:
        L.append(((i+1)*(i//2)+(i//2+1))*(1/i))
S = [0]
for i in range(N):
    S.append(sum(L[0:i+1]))
print(S)
n = 0
for i in range(N-K+1):
    n = max(n,S[i+K]-S[i])
print(n)

Submission status: Wrong Answer

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

max_idx_left = 0
for i in range(1, N-K+1):
    if P[i+K-1] > P[i-1]:
        max_idx_left = i

print(sum([(1+p)/2 for p in P[max_idx_left:max_idx_left+K]]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
ds = map(int,input().split())
exps = [(d+1)/2 for d in ds]
out = 0
for i in range(N-2):
    out = max(out,sum(exps[i:i+K]))
print(out)

Submission status: Wrong Answer

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

e = [(i+1)/2 for i in p]
e = np.cumsum(e)
ans = 0
for i in range(n-k):
    ans = max(e[i+k]-e[i],ans)

print(ans)

Submission status: Wrong Answer

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


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

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

print(tmp)

Submission status: Wrong Answer

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

def kitai(dice):
	#期待値を求める
	return sum(list(range(1,dice+1)))/dice


e=[kitai(x) for x in p]
print(e)
result=[]
for i in range(K,N+1):
	result.append(sum(e[i-K:i]))

		
print(max(result))

Submission status: Wrong Answer

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

def kitai(dice):
	#期待値を求める
	return sum(list(range(1,dice+1)))/dice


result=[]
for i in range(K):
	if (K+i)<=N:
		m=p[i:(K+i)]
		Sum=0
		for j in m:
			Sum+=kitai(j)
		result.append(Sum)
print(max(result))

Submission status: Wrong Answer

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

def kitai(dice):
	#期待値を求める
	S=0
	for p in range(dice):
		S+=p+1
	return S/dice


result=[]
for i in range(K):
	if (K+i)<=N:
		m=p[i:(K+i)]
		Sum=0
		for j in m:
			Sum+=kitai(j)
		result.append(Sum)
print(max(result))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
plist = [((num*(num+1))//2)/num for num in list(map(int, input().split()))]
print(plist)
ans = 0
for i in range(K):
    ans += plist[i]
_ = ans
for i in range(N-K):
    temp = _
    temp -= plist[i]
    temp += plist[i+K]
    # print(i, i+K, ans, temp)
    ans = max(ans, temp)
    _ = temp
print(ans)

Submission status: Wrong Answer

Solution code:
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np #pypy不可
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)
  np.cumsum(p,out=p)
  chk = 0
  
  for i in range(n-k):
    c = p[i+k]-p[i]
    chk = max(c,chk)
  print((chk+k)/2)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np #pypy不可
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)

  chk = 0
  for _ in range(n%k+1):
    L = n+k-n%k
    p.resize(L) # np.resize(p,L) にすると足りない分を繰り返す
    l = p.reshape(-1,k).sum(axis=1)
    #print(l)
    m = max(l)
    chk = max(chk,m)
    p = np.delete(p,0)

  print((chk+k)/2)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

p.sort(reverse=True)
ans = 0
for i in range(K):
    ans += (p[i]+1)/2

print(ans)

Submission status: Wrong Answer

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
p=n1()

from collections import deque
e0=deque()
e1=deque()
e2=deque()
e3=deque()
e1.append(0)
e2.append(0)
e2.append(0)
e3.append(0)
e3.append(0)
e3.append(0)
for x in p:
    y=(1+x)/2
    e0.append(y)
    e1.append(y)
    e2.append(y)
    e3.append(y)
e0.append(0)
e0.append(0)
e0.append(0)
e1.append(0)
e1.append(0)
e2.append(0)
ans=0
for _ in range(len(e0)):
    ans=max(ans,e0.pop()+e1.pop()+e2.pop()+e3.pop())
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, input().split())
p = list(map(int, input().split()))
# 下の同値の場合を除外しないとrange(k,k)=[]となりfor文が回らない
if n == k:
    print((sum(p) + k) / 2)
    sys.exit(0)
saveSum = sum(p[0:k])
M = 0
for i in range(k, len(p)):
    saveSum = saveSum + p[i] - p[i - k]
    print(p[i-k])
    if saveSum > M:
        M = saveSum
print((k+M)/2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
saveSum = sum(p[0:k])
M = 0
for i in range(k, len(p)):
    saveSum = saveSum + p[i] - p[i-k]
    if saveSum > M:
        M = saveSum
print((k+M)/2)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
max_total = 0
res = 0
p = list(map(int,input().split()))
for _ in range(len(p)):
  p[_] = (p[_]+1)/2
  
total = sum(p[0:K])
for i in range(K,N):
  if p[i] > p[i-K]:
    total = total + p[i] - p[i-K]
    max_total = max(max_total,total)
  else:
    total = total + p[i] - p[i-K]
print(max_total)

Submission status: Wrong Answer

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

exv = list()

for a in p:
    exv.append((1+a)/2)