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

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

print(acc)

ans = 0
for i in range(0, N-K+1):
    tmp = acc[i+K] - acc[i]
    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()))
ans = 0
for i in range(k):
  ans += (p[i]+1)/2
if(k<n):
  for i in range(n-k):
    ans = max(ans,ans-(p[i]+1)/2+(p[k+i]+1)/2)
  print(ans)
else:
  print(ans)

Submission status: Wrong Answer

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

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

for i in range(k):
    max += p[i]
print(max)
tmp = max

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

Submission status: Wrong Answer

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

def get_val(a):
    return 1+a/2

current = 0
for i in range(k):
    current += get_val(p_list[i])
max = current

for i in range(k, n):
    current -= get_val(p_list[i-k])
    current += get_val(p_list[i])
    if max < current:
        max = current

print(max)

Submission status: Wrong Answer

Solution code:
from decimal import *

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

def get_val(a):
    return Decimal(sum(range(1, a+1)))/Decimal(a)

max = 0
current = 0
for i in range(k):
    current += get_val(p_list[i])

for i in range(k, n):
    current -= get_val(p_list[i-k])
    current += get_val(p_list[i])
    if max < current:
        max = current

print(max)

Submission status: Wrong Answer

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

def get_val(a):
    return sum(range(1, a+1))/a

max = 0
current = 0
for i in range(k):
    current += get_val(p_list[i])

for i in range(k, n):
    current -= get_val(p_list[i-k])
    current += get_val(p_list[i])
    if max < current:
        max = current

print(max)

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

from collections import deque

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

d_front = deque(p[:k])
d_back = deque(p[k:])

sum_prev = sum(d_front)
ma = sum_prev

while d_back:
    ff = d_front.popleft()
    bf = d_back.popleft()
    sum_curr = sum_prev - ff + bf
    ma = max(ma, sum_curr)
    d_front.append(ff)
    sum_prev = sum_curr
    
print(ma)

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):
  p[i] = (p[i] + 1) / 2

for j in range(K):
  s += p[j]

x = s
 
for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= max(x, t):
    x = t
  else:
    pass
  s = t

print(x)

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):
  p[i] = (p[i] + 1) / 2

for j in range(K):
  s += p[j]

x = s
 
for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print(x)

Submission status: Wrong Answer

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

s = 0
 
for i in range(N):
  p[i] = (p[i] + 1) / 2
 
for j in range(K):
  s += p[j]
  
x = s
 
for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t
 
print('{:.08f}'.format(x))

Submission status: Wrong Answer

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

s = 0

for j in range(K):
  s += p[j]
  
x = s

for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print((x + K) / 2)

Submission status: Wrong Answer

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

s = 0

for j in range(K):
  s += p[j]
  
x = s

for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print((x + K) / 2)

Submission status: Wrong Answer

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

s = 0

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

for j in range(K):
  s += float(p[j])
  
x = s

for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print(x)

Submission status: Wrong Answer

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

s = 0

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

for j in range(K):
  s += p[j]
  
x = s

for k in range(N - K):
  t = s - p[k] + p[K + k]
  if s <= t:
    x = t
  else:
    pass
  s = t

print(x)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

acc=list(accumulate(p))
print(acc)
ans=0
if n==k:
    print(sum(p)/2+0.5*k)
    exit()
for i in range(k,n):
    ans=max(ans,acc[i]-acc[i-k])
print(ans/2+0.5*k)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

acc=list(accumulate(p))
ans=0
for i in range(k,n):
    ans=max(ans,acc[i]-acc[i-k])
print(ans/2+0.5*k)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0

t = [0 for i in range(M+1)]
for i in range(M):
    t[i+1] = t[i] + (1+s[i])/2

for i in range(N,M-N+1):
    count = max(count,t[i]-t[i-N])

print(count)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

t = [0 for i in range(M+1)]
for i in range(M):
    t[i+1] = t[i] + (1+s[i])/2

for i in range(N,M-N+1):
    if t[i] -t[i-N] > count:
        count = t[i] -t[i-N]

print(count)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

t = [0 for i in range(M+1)]
for i in range(M):
    t[i+1] = t[i] + s[i]

for i in range(N,M-N+1):
    if t[i] -t[i-N] > count:
        count = t[i] -t[i-N]
        kiroku = i
b = 0
for i in range(kiroku-N,kiroku):
    a = (1+s[i])/2
    b += a

print(b)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

t = [0 for i in range(M+1)]
for i in range(M):
    t[i+1] = t[i] + s[i]

for i in range(N,M-N+1):
    if t[i] -t[i-N] > count:
        count = t[i] -t[i-N]
        kiroku = i
b = 0
for i in range(kiroku-N,kiroku):
    a = (1+s[i])/2
    b += a

if b >= 0:
    print(b)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

for i in range(M-N):
    if sum(s[i:i+N]) > count:
        count = sum(s[i:i+N])
        kiroku = i


b = 0
for i in range(kiroku,kiroku+N):
    a = (1+s[i])/2
    b += a
    
print(b)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

for i in range(M-N):
    if sum(s[i:i+N]) > count:
        count = sum(s[i:i+N])
        kiroku = i


b = 0
for i in range(kiroku,kiroku+N):
    if s[i]//2 == s[i]/2:
        a = ((1+s[i])*(s[i]//2))/s[i]
    else:
        a = ((1+s[i])*(s[i]//2) + (1+s[i])//2)/s[i]
    b += a
    
print(b)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0

def search(s1,N,h):
    b = 0
    for i in range(N):
        if s1[i+h]//2 == s1[i+h]/2:
            a = ((1+s1[i+h])*(s1[i+h]//2))/s1[i+h]
        else:
            a = ((1+s1[i+h])*(s1[i+h]//2) + (1+s1[i+h])//2)/s1[i+h]
        b += a
    return b
    
for j in range(M-N):
    if search(s,N,j) > count:
        count = search(s,N,j)
print(count)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
 
s1 = sorted(s,reverse = True)
b = 0
for i in range(N):
    if s1[i]//2 == s1[i]/2:
        a = ((1+s1[i])*(s1[i]//2))/s1[i]
    else:
        a = ((1+s1[i])*(s1[i]//2) + (1+s1[i])//2)/s1[i]
    b += a
print(b)

Submission status: Wrong Answer

Solution code:
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))

s1 = sorted(s,reverse = True)
b = 0
for i in range(N):
    if s1[i]//2 == s[i]/2:
        a = ((1+s1[i])*s[i]//2)/s1[i]
    else:
        a = ((1+s1[i])*s[i]//2 + (1+s1[i])//2)/s1[i]
    b += a
print(b)

Submission status: Wrong Answer

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

    max_p = 0
    ind = 0 
    for i in range(N):
        if max_p < dice[i]:
            max_p = dice[i]
            ind = i

    max_exp = 0
    for i in range(max(ind-K, 0), min(ind+K, N)):
        if 0 <= i and i + K - 1 <= N - 1:
            exp = 0
            for j in range(i, i+K):
                exp += (dice[j]+1)/2.0

            if max_exp < exp:
                max_exp = exp
                
    print(max_exp)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k = map(int, stdin.readline().rstrip().split())
p = list(map(int, stdin.readline().rstrip().split()))

ss = []

for i in range(n):
    s = (p[i]+1) / 2
    if i == 0:
        ss.append(s)
    else:
        ss.append(ss[len(ss)-1] + s)

ans = 0

for i in range(n-k+1):
    a = ss[n-i-1] - ss[n-k-i-1]
    if a > ans:
        print
        ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=sum([p[i] for i in range(k)])
ans=0
for i in range(n-k):
  l-=p[i]
  l+=p[i+k]
  ans=max(l,ans)
print('{:.7f}'.format((ans+k)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
acc = [0] + list(itertools.accumulate([(x+1)/2 for x in p])) # 累積和を計算
 
ans = max(acc[i]-acc[i-k] for i in range(k, n+1)) # k番目からn番目まで計算

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p_exp = [(p[i] + 1)/2 for i in range(n)]

s = [sum(p_exp[0:i]) for i in range(n)]

ans = -1


for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    if i >= 1:
        sum_exp = s[k_end] - s[k_start - 1]
    else:
        sum_exp = s[0]
    ans = max(sum_exp, ans)

print(ans)

Submission status: Wrong Answer

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

p_exp = [(p[i] + 1)/2 for i in range(n)]

s = [sum(p_exp[0:i]) for i in range(n)]

ans = -1


for i in range(0, n-k+1):
    k_start = i
    k_end = i + k - 1
    sum_exp = s[k_end] - s[k_start - 1]
    ans = max(sum_exp, ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
def kitai(num):
    return (1+int(num)/2)
P = list(map(kitai,input().split()))	  

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

Submission status: Wrong Answer

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

def get_expectation (x):
    return (int(x)+1)/2
exp = list(map(get_expectation,input().split()))

maxim = 0
for i in range(N-K):
    totalk = sum(exp[i:i+K])
    
    if maxim <= totalk:
        maxim = totalk

print(maxim)

Submission status: Wrong Answer

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

d={}

for i in range(n):
  if l[i] not in d:
    d[l[i]]=(l[i]+1)/2

#print(d)

dp=[]
dp.append(d[l[0]])
for i in range(1,n):
  dp.append(dp[i-1]+d[l[i]])

#print("this is dp",dp)

mx=0
for i in range(n-k):
  we=dp[i+k]-dp[i]
  if we>=mx:
    mx=we
print("{:.6f}".format(mx))

Submission status: Wrong Answer

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

d={}

for i in range(n):
  if l[i] not in d:
    d[l[i]]=(l[i]+1)/2

#print(d)

dp=[]
dp.append(d[l[0]])
for i in range(1,n):
  dp.append(dp[i-1]+d[l[i]])

#print("this is dp",dp)

mx=0
for i in range(n-k):
  we=dp[i+k]-dp[i]
  if we>mx:
    mx=we
print(mx)

Submission status: Wrong Answer

Solution code:
import copy
n,k=map(int,input().split())
p=list(map(int,input().split()))
sum_p=[]
wk_sum_p=[]
for i in range(n):
  wk_sum_p.append(p[i])
  if len(wk_sum_p)==k:
    sum_p=copy.deepcopy(wk_sum_p)
  elif len(wk_sum_p)>k:
    if wk_sum_p[0]<wk_sum_p[k]:
      sum_p=copy.deepcopy(wk_sum_p[1:k+1])
    del wk_sum_p[0]
ans=0
for val in sum_p:
  div=val//2
  if val%2==0:
    ans+=(1+val)*div/val
  else:
    ans+=((2+val)*div+1)/val
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
sum_p=[]
wk_sum_p=[]
for i in range(n):
  wk_sum_p.append(p[i])
  if len(wk_sum_p)==k:
    sum_p=wk_sum_p.copy()
  elif len(wk_sum_p)>k:
    if wk_sum_p[0]<wk_sum_p[k]:
      sum_p=wk_sum_p[1:k+1].copy()
    del wk_sum_p[0]
ans=0
for val in sum_p:
  div=val//2
  if val%2==0:
    ans+=(1+val)*div/val
  else:
    ans+=((2+val)*div+1)/val
print(ans)

Submission status: Wrong Answer

Solution code:

N, K = map(int,input().split())
P = list(map(int,input().split()))
def calc_cumulative_sum(idx,_list):
    return 0

expected = []
cumulative_sum_expected = []
_sum = 0
for v in P:
    expected.append((1+v)/2) 
    _sum += (1+v)/2
    cumulative_sum_expected.append(_sum)
ans = 0
for i in range(K,N):
    if ans < cumulative_sum_expected[i]-cumulative_sum_expected[i-K]:
        ans = cumulative_sum_expected[i]-cumulative_sum_expected[i-K]
print(ans)

Submission status: Wrong Answer

Solution code:
N ,K = list(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:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    # print(E)

    p = E[0]
    mx = -1
    for j in range(k, n):
        diff = E[j] - E[j-k]
        if mx < diff:
            mx = diff
    print(mx)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p = list(map(int,input().split()))
m = [(maximum + 1) / 2 for maximum in p]#平均値のリスト m を作って、幅 K の Sliding Window 
print(m)
t = sum(m[0:K])#K番目までの合計
result = t#初期結果
for i in range(N - K):
    t -= m[i]#末尾引いて
    t += m[i + K]#新しいのタス
    if t > result:
        result = t
print(result)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P = list(map(int,input().split()))
#1-li[i]に関する期待値
dp_e=[0]*(N+1)
S=[0]*(N+1)
ans=0
#あらかじめ期待値を用意
for i in range(N):
  if P[i]==1:
  	dp_e[i+1]=0.5
  else:
    dp_e[i+1]=(1+ P[i])
  S[i+1]=S[i]+dp_e[i+1]
ans=0
for i in range(N-K+1):
  if ans<(S[i+K]-S[i]):
    ans=(S[i+K]-S[i])
print(ans/2)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P = list(map(int,input().split()))
dp_e=[0]*(N+1)
S=[0]*(N+1)
ans=0
for i in range(N):
  if P[i]==1:
  	dp_e[i+1]=0.5
  else:
    dp_e[i+1]=(1+ P[i])/2
  S[i+1]=S[i]+dp_e[i+1]
ans=0
for i in range(N-K+1):
  if ans<(S[i+K]-S[i]):
    ans=(S[i+K]-S[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P = list(map(int,input().split()))
#1-li[i]に関する期待値
dp_e=[0]*(N+1)
S=[0]*(N+1)
ans=0
#あらかじめ期待値を用意
for i in range(N):
  if P[i]==1:
  	dp_e[i+1]=0.5
  else:
    dp_e[i+1]=(1+ P[i])/2
  S[i+1]=S[i]+dp_e[i+1]
ans=0
for i in range(N-K+1):
  if ans<(S[i+K]-S[i]):
    ans=(S[i+K]-S[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
e=[(i+1)*0.5 for i in p]
ex=[]

for i in range(N):
  if i==0:
    ex.append(e[0])
  else:
    ex.append(ex[i-1]+e[i])

ans=0
for i in range(N-K):
  if ans<ex[i+K]-ex[i]:
    ans=ex[i+K]-ex[i]
print(ans)

Submission status: Wrong Answer

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

c_s_list = [] #Cumulative sum_list
c_sum = 0 #Cumulative sum
for dice in p_list:
    average = (dice + 1) / 2 #ダイスの期待値
    c_sum += average
    c_s_list.append(c_sum)

ans = 0
for i in range(N-K):
    tmp = c_s_list[i+K] - c_s_list[i]
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

c_s_list = [] #Cumulative sum_list
c_sum = 0 #Cumulative sum
for dice in p_list:
    average = (dice + 1) / 2 #ダイスの期待値
    c_sum += average
    c_s_list.append(c_sum)

ans = 0
for i in range(N-K):
    tmp = c_s_list[i+K] - c_s_list[i]
    if tmp > ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


ruisekiwa_list = []
for saikoro in p_list:
    ruisekiwa = (1 + saikoro) / 2
    ruisekiwa_list.append(ruisekiwa)
sum_K_max = 0
for i in range(N-K):
    sum_K = ruisekiwa_list[i + K] - ruisekiwa_list[i]
    if sum_K_max < sum_K:
        sum_K_max = sum_K
print(sum_K_max)

Submission status: Wrong Answer

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


ruisekiwa_list = []
ruisekiwa = 0
for saikoro in p_list:
    ruisekiwa += (1 + saikoro) / 2
    ruisekiwa_list.append(ruisekiwa)

sum_K_max = 0
for i in range(N-K):
    sum_K = ruisekiwa_list[i + K] - ruisekiwa_list[i]
    if sum_K_max < sum_K:
        sum_K_max = sum_K
print(sum_K_max)

Submission status: Wrong Answer

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


def ave(num):
    return (1 + num) / 2

ruisekiwa_list = []
ruisekiwa = 0
for saikoro in p_list:
    ruisekiwa += ave(saikoro)
    ruisekiwa_list.append(ruisekiwa)

sum_K_max = 0
for i in range(N-K):
    sum_K = ruisekiwa_list[i + K] - ruisekiwa_list[i]
    if sum_K_max < sum_K:
        sum_K_max = sum_K
print(sum_K_max)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import accumulate
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = []
b = list(accumulate(range(1, N+1)))
for i in range(N-K+1):
    E = 0
    for k in range(K):
        E += b[i+k]/p[i+k]
    e.append(E)
print(max(e))

Submission status: Wrong Answer

Solution code:
def cal_expectation(list,index,option):
  expect = 0
  for i in range(index,index+option):
    expect += list[i]*(list[i]+1)/(2*list[i])
  return expect

problem_info = input().split()
dice_num = int(problem_info[0])
option_num = int(problem_info[1])

prob_list = [int(i) for i in input().split()]
max = -1
max_index = 0

for i in range(len(prob_list) -option_num + 1):
  sum_prob = 0
  for j in range(i,i+option_num):
    sum_prob += prob_list[j]
  if max < sum_prob:
    max = sum_prob
    max_index = i
    
print(prob_list)
print(max_index)

print(cal_expectation(prob_list,max_index,option_num))

Submission status: Wrong Answer

Solution code:
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in p]
ruiseki=[ex[0]]
ans=0

for i in range(1,N):
  ruiseki.append(ruiseki[i-1]+ex[i])


for i in range(N-K):
  if ans<ruiseki[i+K]-ruiseki[i]:
    ans=ruiseki[i+K]-ruiseki[i]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N, p, K):
    ans = sum(p[:K])
    print(N, K, P)
    #ans = 0
    ans = c.copy(sum(p[:K]))
    sm = c.copy(ans)
    for i in range(K, N):
        print(i-K, p[i-K], i, p[i])
        sm = sm - p[i-K] + p[i]
        ans = max(ans, sm)
        print(ans)
    return ans


print(1/2.0 * k + 1.0/2 * solve(n, P, k))

Submission status: Wrong Answer

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


def solve(N, p, K):
    ans = sum(p[:K])
    print(N, K, P)
    #ans = 0
    ans = sum(p[:K])
    sm = c.copy(ans)
    for i in range(K, N):
        print(i-K, p[i-K], i, p[i])
        sm = sm - p[i-K] + p[i]
        ans = max(ans, sm)
        print(ans)
    return ans


print(1/2.0 * k + 1.0/2 * solve(n, P, k))

Submission status: Wrong Answer

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


def solve(N, p, K):
    # ans = sum(p[:K])
    # print(P)
    ans = 0
    for i in range(K, N):

        # print(ans, i-K, i)
        # print(p[i-K:i], sum(p[i-K:i]))
        # ans = max(ans - p[i-K] + p[i], ans)
        ans = max(ans, sum(p[i-K:i]))
    return ans


print(1/2.0 * k + 1.0/2 * solve(n, P, k))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
dnum = [0] * n
tsum = 0
for i in range(n):
  tsum += (p[i] + 1) / 2.0
  dnum[i] = tsum
kdmax = 0
for j in range(n - k):
  kdiff = dnum[j + k] - dnum[j]
  if kdiff > kdmax:
    kdmax = kdiff
print(kdmax)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
sump = [0 for _ in range(n)]
sump[0] = (1 + int(p[0])) / 2
for i in range(1,n):
    sump[i] = sump[i-1] + (1 + p[i]) / 2
maxsump = 0
for i in range(n-k):
    sussump = sump[i+k] - sump[i]
    if maxsump < sussump: maxsump = sussump
print(maxsump)

Submission status: Wrong Answer

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

MAX = 0
for i in range(N-K):
    SUM = 0
    for j in range(K):
        SUM += (A[i+j]+1)/2

    if MAX < SUM:
        MAX = SUM

print(MAX)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
ans_o = 0
for j in range(k):
    ans_o += p_list[0 + j]
for i in range(1,n-k+1):
    ans = ans_o-p_list[i-1]+p_list[i+k-1]
#    print(ans)
    if ans > ans_o:
        save = i
    ans_o = ans
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
dum = 0
for j in range(k):
    dum += p_list[0 + j]
for i in range(1,n-k+1):
    ans = dum-p_list[i-1]+p_list[i+k-1]
#    print(ans)
    if ans > dum:
        save = i
    dum = ans
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
dum = 0
for j in range(k-1):
    dum += p_list[0 + j]
for i in range(1,n-k+1):
    ans = dum-p_list[i-1]+p_list[i+k-1]
    if ans > dum:
        save = i
        dum = ans
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
dum = 0
for j in range(k):
    dum += p_list[0 + j-1]
for i in range(1,n-k+1):
    ans = dum-p_list[i-1]+p_list[i+k-1]
    if ans > dum:
        save = i
        dum = ans
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
dum = 0
for j in range(k):
    dum += p_list[0 + j]
for i in range(1,n-k+1):
    ans = dum-p_list[i-1]+p_list[i+k-1]
    if ans > dum:
        save = i
        dum = ans
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
E = 0
for i in range(1,K+1):
    n = lis[i-1]
    E += (n+1)/2
print(E)

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
ans = 0
tmp = 0
for i in range(k):
    tmp += p[i]
for i in range(1,n - k + 1):
    tmp = tmp - p[i - 1] + p[i + k - 1]
    if ans < tmp:
        ans = tmp
print("{:.12f}".format(ans))

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
ans = 0
tmp = 0
for i in range(k):
    tmp += p[i]
for i in range(1,n - k + 1):
    tmp = tmp - p[i - 1] + p[i + k - 1]
    if ans < tmp:
        ans = tmp
print("{:.10f}".format(ans))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
for i in range(N):
    Px.append((1+P[i])/2)
temp_num = sum(Px[0:K])
temp_max = sum(Px[0:K])
for j in range(N-K-1):
    temp_num = temp_num-Px[j]+Px[j+K+1]
    if temp_max <temp_num:
        temp_max=temp_num
    if j==(N-K-1):
        break
print(temp_max)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
for i in range(N):
    Px.append((1+P[i])/2)
temp_num = sum(Px[0:K])
temp_max = sum(Px[0:K])
for j in range(N-K+1):
    temp_num = temp_num-Px[j]+Px[j+K-1]
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
for i in range(N):
    Px.append((1+P[i])/2)
temp_num = sum(Px[0:K])
temp_max = 0
for j in range(N-K+1):
    if temp_max <temp_num:
        temp_max=temp_num
    temp_num = temp_num-Px[j]+Px[j+K-1]
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

temp_num = sum(line[0:K])
temp_max = temp_num

for i in range(N - K):
    temp_num = temp_num - line[i] + line[i + K]
    if temp_num > temp_max:
        temp_max = temp_num


print((1 + temp_max) / 2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) // 2) / x, l))
l = sorted(l)
print(sum(l[-k:]))

Submission status: Wrong Answer

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    Et = [0]*(N+1)
    for i in range(N):
        Et[i] = Et[i-1] + (1+P[i])/2
    ret = 0
    for i in range(N-K+1):
        ret = max(ret, Et[i+K]-Et[i])
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def expect(p):
  return (1+p)/2

maxV = sum([expect(p) for p in P[:K]])
for i in range(N-K):
  maxV = max(maxV, maxV - expect(P[i]) + expect(P[i+K]))
print(maxV)