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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    p = [((int(i)+1) * int(i) / 2)/int(i) for i in input().split()]
    dp = [0 for i in range(N-K+1)]
    dp[0] = 0
    for i in range(1, N-K+1):
        dp[i] = max(dp[i-1], sum(j for j in p[i:i+K]))
    print(max(dp))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(len(p)):
    p_sum.append(p_sum[i] + (p[i]+1)/2) 
print(p_sum)

for i in range(K,N+1):
    sum = p_sum[i] - p_sum[i-K]
    print(sum)
    if(max < sum):
        max = sum
print('{:.12f}'.format(max))

Submission status: Wrong Answer

Solution code:
import collections

def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
p_list = get_input_line()

def calc_dice_score(p):
    return 0.5*(p+1)

def calc_score(score_list):
    return sum(score_list)

dice_scores = [0] * n

max_score = 0
tmp_score = 0

for i in range(k):
    dice_scores[i] = 0.5*(p_list[i]+1)
    tmp_score += dice_scores[i]

max_score = tmp_score
    
for i in range(n- k + 1):
    dice_scores[i+k-1] = 0.5*(p_list[i+k-1]+1)
    tmp_score -= dice_scores[i]
    tmp_score += dice_scores[i+k-1]
    max_score = max(max_score, tmp_score)
print(max_score)

Submission status: Wrong Answer

Solution code:
import collections

def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
p_list = get_input_line()

def calc_dice_score(p):
    return 0.5*(p+1)

def calc_score(score_list):
    return sum(score_list)

dice_scores = [0] * n

max_score = 0
tmp_score = 0

for i in range(k):
    dice_scores[i] = 0.5*(p_list[i]+1)
    tmp_score += dice_scores[i]

max_score = tmp_score
    
for i in range(1, n- k + 1):
    dice_scores[i+k-1] = 0.5*(p_list[i+k-1]+1)
    tmp_score -= dice_scores[i]
    tmp_score += dice_scores[i+k-1]
    max_score = max(max_score, tmp_score)
print(max_score)

Submission status: Wrong Answer

Solution code:
import collections

def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
p_list = get_input_line()

def calc_dice_score(p):
    return 0.5*(p+1)

def calc_score(score_list):
    return sum(score_list)

dice_scores = [0] * n

max_score = 0

for i in range(k):
    dice_scores[i] = 0.5*(p_list[i]+1)

for i in range(n- k + 1):
    dice_scores[i+k-1] = 0.5*(p_list[i+k-1]+1)
    max_score = max(max_score, 1)#sum(dice_scores[i:i+k]))
print(max_score)

Submission status: Wrong Answer

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

#左からn番目のダイスを振ったときの期待値を求める
E = [(i+1)/2 for i in p]
E_reverse = sorted(E, reverse=True)

print(sum(E_reverse[0:K]))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
E = [(v+1)/2 for v in L]
tmp = sum(E[:K])
ans = tmp
for l, p in zip(E[K:], E):
    tmp = tmp-l+p
    ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
E = [(v+1)/2 for v in L]
tmp = sum(E[:K])
ans = tmp
print(E)
for l, p in zip(E[K:], E):
    tmp = tmp-l+p
    ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
E=[(v+1)/2 for v in L]
ans=sum(E[:K])
for l,p in zip(E[K:],E):
  ans = max(ans,ans-p+l)
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
E=[(v+1)/2 for v in L]
ans=sum(E[:K])
last=E[0]
for l in E[K:]:
  ans = max(ans,ans-last+l)
  last = l
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
E=[(v+1)//2 for v in L]
ans=sum(E[:K])
last=E[0]
for l in E[K:]:
  ans = max(ans,ans-last+l)
  last = l
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
AN = list(map(int, input().split()))
 
def Estimator(x):
  return (x + 1)/2
 
m = []
for i in range(N-K+1):
  B = 0
  for A in AN[i:i+K-1]:
    B += Estimator(A)
  m.append(B)
 
print(max(m))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split(" "))
dices_e = [float((e+1)/2) for e in list(map(int, input().split(" ")))]
e = max_e = sum(dices_e[:k+1])
for i in range(1, n-k+1):
  e = e - dices_e[i-1] + dices_e[i+k-1]
  if e>max_e:
    max_e = e

print(max_e)

Submission status: Wrong Answer

Solution code:
import itertools

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

pa = list(itertools.accumulate(p))

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split(" "))
dices = list(map(int, input().split(" ")))
dices_e = [float(e*(e+1)/(2*e)) for e in dices]
max_e = 0.0
for i in range(n-k+1):
  e = sum(dices_e[i:i+k+1])
  if e>max_e:
    max_e = e

print(max_e)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split(" "))
dices = list(map(int, input().split(" ")))
dices_e = [float(e*(e+1)/(2*e)) for e in dices]
max_e = 0.0
for i in range(n-k+1):
  e = sum(dices_e[i:i+k])
  if e>max_e:
    max_e = e

print(e)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split(" "))
dices = list(map(int, input().split(" ")))
dices_e = [float(e*(e+1)/(2*e)) for e in dices]

max_e = 0.0
for i in range(n-k+1):
  e = sum(dices[i::i+k])
  if e>max_e:
    max_e = e

print(e)

Submission status: Wrong Answer

Solution code:
n, k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
max_t = 0
ans = 0
for i in range(n - k + 1):
    buf = sum(p[i:i + k])
    if max_t < buf:
        max_t = buf
        ans = 0
        for j in range(k):
            ans += (1 + p[i + j]) * p[i + j] / 2
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
pi = list(map(int,input().split()))
pi.sort(reverse=True)

ans = 0
for p in pi[:K]:
  ans += (p+1)/2
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
pi = list(map(int,input().split()))
pi.sort(reverse=True)

ans = 0
for p in range(K):
  dice = [i+1 for i in range(pi[p])]
  ans += sum(dice)/pi[p]
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = (int(z) for z in input().split())
a = [int(z) for z in input().split()]
a = [0] + a
for i in range(1, len(a)):
  a[i] += a[i - 1]
mx = 0
for i in range(k, len(a)):
  mx = max(mx, (a[i] - a[i - k]) / 2)
print(mx)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
n = nk[0]
k = nk[1]
maxnum = -100
for i in range(n-k):
    if p[i] <= p[i+k]:
        if i == n-k-1:
            maxnum = sum(p[n-k:])
            break
        if sum(p[i:i+k]) >= maxnum:
            maxnum = sum(p[i:i+k])

ans = (maxnum+k)/2
print(ans)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
n = nk[0]
k = nk[1]
maxnum = 0
for i in range(n-k):
    if p[i+k] >= p[i]:
        maxnum = i+k

ans = (sum(p[maxnum-k+1:maxnum+1])+k)/2
print(ans)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
n = nk[0]
k = nk[1]
maxnum = 0
for i in range(k, n):
    if p[i] >= p[i-k]:
        maxnum = i

ans = (sum(p[maxnum-k+1:maxnum+1])+k)/2
print(ans)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
n = nk[0]
k = nk[1]
maxnum = 0
for i in range(2, n):
    if p[i] >= p[i-2]:
        maxnum = i

ans = (sum(p[maxnum-k+1:maxnum+1])+k)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = list(map(int, input().split()))
num_array = np.cumsum(list(map(lambda x: (x+1)/2, list(map(int, input().split())))))

max_exp = 0
for i in range(len(num_array)-M):
    tmp = num_array[i+M] - num_array[i]
    if max_exp < tmp:
        max_exp = tmp

print(max_exp)

Submission status: Wrong Answer

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

SUM = 0
for i in range(N-K):
    if sum(E[i:i+K]) > SUM:
        SUM = sum(E[i:i+K])
        
print(SUM)

Submission status: Wrong Answer

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

processed = list(map(lambda x: (1+x)/2, num_array))

print(processed)
expected = []
for i in range(len(num_array) - M + 1):
    expected.append(sum(processed[i:i+M]))

print(max(expected))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int,input().split())
P = list(map(int,input().split()))
cumsum = np.cumsum(P)
np.insert(cumsum,0,0)
maxs = 0
for i in range(N-K):
    temp = cumsum[i+K] - cumsum[i]
    maxs = max(maxs, temp)
print((maxs+K)/2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int,input().split())
P = list(map(int,input().split()))
cumsum = np.cumsum(P)
maxs = 0
for i in range(N-K):
    temp = cumsum[i+K] - cumsum[i]
    maxs = max(maxs, temp)
print((maxs+K)/2)

Submission status: Wrong Answer

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

pp = [0] + list(accumulate(p))

m = 0
for i in range(n - k + 1):
  m = max(m,pp[i + k] - pp[i - 1])
print((m+k)/2)

Submission status: Wrong Answer

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

pp = [0] + list(accumulate(p))

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

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N+1-K):
  number_sum = sum(numbers[i:i+K])
  if number_sum > maxvalue:
    maxvalue = number_sum
    
answer = (maxvalue + 3) / 2
print(answer)

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N-K):
  number_sum = sum(numbers[i:i+K])
  if number_sum > maxvalue:
    maxvalue = number_sum
    
answer = (maxvalue + 3) / 2
print(answer)

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N-K):
  number_sum = sum(numbers[i:i+K])
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print((maxvalue + 3) / 2)

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N-K):
  number_sum = sum(numbers[i:i+K])
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print(maxvalue + 3 / 2)

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N-K):
  number_sum = sum(numbers[i:i+K])
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print(maxvalue)

Submission status: Wrong Answer

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

maxvalue = 0
for i in range(N-2):
  number_sum = numbers[i] + numbers[i+1] + numbers[i+2]
  if number_sum > maxvalue:
    maxvalue = number_sum
    
print(maxvalue)

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p =[]
for i in b:
    p.append((i+1)/2)
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s<s:
        max_s=s
print(max_s)

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in range(N):
    p[i] = (1+p[i])/2
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s<s:
        max_s=s
print(max_s)

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in range(N):
    p[i] = (1+p[i])/2
s = sum(p[:K])
max_s = s
for i in range(N-K):
    if max_s < sum(p[i:K+i]):
        max_s = sum(p[i:K+i])

print(max_s)

Submission status: Wrong Answer

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

# i番目まで加算した配列を作成
psum = [0] * (n+k)
psum[0] = (ps[0]+1)/2
for i in range(1, n):
  psum[i] = psum[i-1] + (ps[i]+1)/2

# k幅の処理を行う
pdeff = [0] * n
# n=kの時の処理
if (k == n):
  for i in range(n):
    pdeff[0] += psum[i] 
# その他の場合の処理
else:
  for i in range(n):
    pdeff[i] = psum[k+i] - psum[i]
  print(max(pdeff))

Submission status: Wrong Answer

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

# i番目まで加算した配列を作成
psum = [0] * (n+k)
psum[0] = (ps[0]+1)/2
for i in range(1, n):
  psum[i] = psum[i-1] + (ps[i]+1)/2

# k幅の処理を行う
pdeff = [0] * n
for i in range(n):
  pdeff[i] = psum[k+i] - psum[i]

print(max(pdeff))

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
# 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)])
 
def main():
    n,k = inpm()
    p = inpl()
    for i in range(n):
        p[i] = (1+p[i])/2
    cnt,ans = 0,0
    for i in range(k):
        cnt += p[i]
    for i in range(n-k):
        ans = max(ans,cnt)
        cnt -= p[i]
        cnt += p[i+k]
        ans = max(ans,cnt)
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 16:38:08 2020

@author: matsui
"""

N,K=map(int,input().split())
p=[int(num) for num in input().split()]

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

M=0
for i in range(N-K):
    if dp[i+K]-dp[i] > M: M=dp[i+K]-dp[i]
    
print(M)

Submission status: Wrong Answer

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

for i in range(N):
  ans.append((nums[i]+1)/2)

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

print(M)

Submission status: Wrong Answer

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

pp = [0] + list(accumulate(p))

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

Submission status: Wrong Answer

Solution code:

nk = list(map(int, input().split()))
p = list(map(int, input().split()))
s=0
summo=0
l = []
for i in range(1,1001):
    s += i
    l.append(s/i)

for i in range(nk[1]):
    summo += l[p[i]-1]
now = 0
for i in range(nk[0]-nk[1]):

    now = summo-l[p[i]-1]+l[p[nk[1]+i]-3]
    if summo<=now:
        summo = now
print(summo)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
s=0
summo=0
l = []
for i in range(1,1001):
    s += i
    l.append(s/i)

for i in range(nk[1]):
    summo += l[p[i]-1]
now = 0
for i in range(nk[0]-nk[1]):

    now = summo-l[p[i]-1]+l[p[nk[1]+i]-3]

    if summo<=now:
        summo = now
 

print(summo)

Submission status: Wrong Answer

Solution code:

nk = list(map(int, input().split()))
p = list(map(int, input().split()))
s=0
summo=0
l = []
for i in range(1,1001):
    s += i
    l.append(s/i)

for i in range(nk[1]):
    summo += l[p[i]-1]
now = 0
for i in range(nk[0]-nk[1]):
    print(now,summo)
    now = summo-l[p[i]-1]+l[p[nk[1]+i]-3]
    print(now, summo)
    if summo<=now:
        summo = now
    print(now, summo)

print(summo)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
p = list(map(int, input().split()))
s=0
summo=0
l = []
for i in range(1,1001):
    s += i
    l.append(s/i)

for i in range(nk[1]):
    summo += l[p[i]-1]

for i in range(nk[0]-nk[1]):
    now = summo-l[p[i]-1]+l[p[nk[1]+i]-1]
    if summo<=now:
        summo = now

print(summo)

Submission status: Wrong Answer

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

res = float('-inf')

for i in range(0, N - K + 1):
    sum = 0
    for x in p[i:i+K]:
        for j in range(x):
            sum = sum + ((j + 1) * 1 / x)  
    if sum > res:
        res = sum

print(sum)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
print(sum(p[:k]) / 2)

Submission status: Wrong Answer

Solution code:
query=[int(x) for x in input().split()]
N = query[0]
K = query[1]
L = list()
L = [int(x) for x in input().split()]



def prob(x):
    out = 0.0

    out = (1 / x) * (x*(x+1))/2

    return out


final = 0.0
answer=list()
for i in range(0, N):
    final=0.0
    for j in range(i, K+i):
        if K+i<=N:
            div = L[j]
            final = final + prob(div)
    answer.append(final)
print(answer)
print("%14.12f"%max(answer))

Submission status: Wrong Answer

Solution code:
query=[int(x) for x in input().split()]
N = query[0]
K = query[1]
L = list()
L = [int(x) for x in input().split()]



def prob(x):
    out = 0.0
    for i in range(1, x + 1):
        out = out + (1 / x) * i

    return out


final = 0.0
answer=list()
for i in range(0, N):
    final=0.0
    for j in range(i, K+i):
        if K+i<N:
            div = L[j]
            final = final + prob(div)
    answer.append(final)

print("%14.12f"%max(answer))

Submission status: Wrong Answer

Solution code:
query=[int(x) for x in input().split()]
N = query[0]
K = query[1]
L = list()
L = [int(x) for x in input().split()]
L.sort(reverse=True)


def prob(x):
    out = 0.0
    for i in range(1, x + 1):
        out = out + (1 / x) * i
    return out


final = 0.0
for i in range(0, K):
    div = L[i]
    final = final + prob(div)

print("%14.12f"%final)

Submission status: Wrong Answer

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

total = sum(P[:k])
start = 0
for i in range(1, n - k):
    tmp = sum(P[i:i + k])
    if total < tmp:
        total = tmp
        start = i

ret = 0
for i in range(start, start + k):
    ret += (P[i] + 1) / 2
print(ret)

Submission status: Wrong Answer

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

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

ans = 0
max_s = s[0]
max_i = 0
for i in range(k, n):
    print(i, i-k)
    s[i-k+1] = s[i-k] + p[i] - p[i-k]
    if s[i-k+1] > max_s:
        max_s = s[i-k+1]
        max_i = i-k+1

ans = 0
for i in range(max_i, max_i+k):
    ans += p[i] * (p[i]+1) / 2 / p[i]

print("%.8f" % ans)

Submission status: Wrong Answer

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

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

ans = 0
max_s = s[0]
max_i = 0
for i in range(k, n):
    print(i, i-k)
    s[i-k+1] = s[i-k] + p[i] - p[i-k]
    if s[i-k+1] > max_s:
        max_s = s[i-k+1]
        max_i = i-k+1

ans = 0
for i in range(max_i, max_i+k):
    ans += p[i] * (p[i]+1) / 2 / p[i]

print(ans)

Submission status: Wrong Answer

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

mm = 0
idx = 0


for i in range(0,len(nums)-3):
    curr = sum(nums[i:i+k])
    if curr > mm:
        mm = curr
        idx = i

s = 0
for i in range(idx,idx+k):
    s += (nums[i]+1)/2
print(s)

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

# print(l)

n = 0
for i in range(N):
    n += l[i]
    l[i] = n

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
l = []
import numpy as np
for i in range(1, N + 1):
    tmp = np.asarray(range(P[i - 1] + 1)).cumsum()
    l.append(int(tmp[-1]) / (P[i - 1]))

# print(l)

n = 0
for i in range(N):
    n += l[i]
    l[i] = n

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

print(ans)

Submission status: Wrong Answer

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

total = sum(P[:k])
start = 0
for i in range(0, n - k):
    tmp = total - P[i] + P[i + k]
    if total < tmp:
        total = tmp
        start = i + 1

ret = 0
for i in range(start, start + k):
    ret += (P[i] + 1) / 2

print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def expect(x):
    prob = 1 / float(x)
    return sum(np.arange(1, x+1)) * prob

p_mapped = [expect(i) for i in p]

p_m_cumsum = np.cumsum(p_mapped)

max = 0
for i in range(K, len(p_mapped)):
    answer = p_m_cumsum[i] - p_m_cumsum[i-K]
    if answer >= max:
        max = answer
print(max)

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
p = [sum(range(1,int(i)+1))/int(i) for i in input().split()]
max = 0
limit = n - k
for i in range(limit):
    sums = sum([p[j] for j in range(i,i+k)])
    if sums > max:
        max = sums
print(max)

Submission status: Wrong Answer

Solution code:
n,k = tuple(map(int,input().split())) 
N = list(map(int,input().split()))
s = sum(N[0:k])
m = sum(N[0:k])

for i in range(0,n-k):
    s = s-N[i]+N[i+k]
    m = max(m,s)   
print((s+k)/2)

Submission status: Wrong Answer

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

for i in range(0,n-k):
    s = max(s,s-N[i]+N[i+k])
        
print((s+k)/2)

Submission status: Wrong Answer

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

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

S = []
for i in range(len(P)):
    if(i > 0):
        S.append(P[i]+S[i-1])
    else:
        S.append(P[0])
# print(S)

max = 0
for i in range(len(S)-K):
    if(range(len(S))==1):
        a = S[0]
    a = S[i+K]-S[i]

    if(a > max):
        max = a

# max = 0

# for i in range(len(P)-K+1):
#     num = 0
#     for j in range(K):
#         num += P[i+j]
#         # print(P[i+j],end=" ")
#     # print(num)
#     if(max < num):
#         max = num

print("{0:6f}".format(max))

Submission status: Wrong Answer

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

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

S = []
for i in range(len(P)):
    if(i > 0):
        S.append(P[i]+S[i-1])
    else:
        S.append(P[0])
print(S)

max = S[0]
for i in range(len(S)-K):
    a = S[i+K]-S[i]

    if(a > max):
        max = a

# max = 0

# for i in range(len(P)-K+1):
#     num = 0
#     for j in range(K):
#         num += P[i+j]
#         # print(P[i+j],end=" ")
#     # print(num)
#     if(max < num):
#         max = num

print("{0:6f}".format(max))

Submission status: Wrong Answer

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

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

S = []
for i in range(len(P)):
    if(i > 0):
        S.append(P[i]+S[i-1])
    else:
        S.append(P[0])
# print(S)

max = 0
for i in range(len(S)-K):
    a = S[i+K]-S[i]

    if(a > max):
        max = a

# max = 0

# for i in range(len(P)-K+1):
#     num = 0
#     for j in range(K):
#         num += P[i+j]
#         # print(P[i+j],end=" ")
#     # print(num)
#     if(max < num):
#         max = num

print("{0:6f}".format(max))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
from itertools import accumulate
A =  [0] + list(accumulate(p))

M = 0
index = 0
for x in range(N - K + 1):
    if M < A[x+K] - A[x]:
        M = A[x+K] - A[x]
        index = x
        #print(x,M)
p = p[ x -1:x - 1 + K]
p = print(sum(map(lambda x:(x+1)/2,p[:K])))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
p = sorted(list(map(int,input().split())))[::-1]
p = print(sum(map(lambda x:(x+1)/2,p[:K])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
p = list(map(int,input().split()))
max_array = sum(p[0:k])
a = math.ceil(k)
u = max_array
for i in range(k, n):
    u = u + p[i]-p[i-k]
    max_array = max(max_array, u)
print((max_array+k) / 2)
print("test")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))

s=[(1/2)*x*(x+1)/x for x in P]
number=len(P)-k+1
print(np.max(np.convolve(s,np.ones(number)/number,mode='same'))*number)

Submission status: Wrong Answer

Solution code:
def expected(n):
  return n/2 + 0.5

n, k = map(int, input().split())
nums = list(map(lambda x: expected(int(x)), input().split()))

highest = 0
for i in range(n):
  if i + 2 > n -1 : break
  score = nums[i] + nums[i+1] + nums[i+2]
  if score > highest: highest = score
print(highest)

Submission status: Wrong Answer

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

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

print('{:.20f}'.format((ans+k)/2))

Submission status: Wrong Answer

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

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

ht=(ans+k)/2
print('{:.20f}'.format(ht))

Submission status: Wrong Answer

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

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

ht=(ans+k)/2
print('{:.10f}'.format(ht))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

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

b=list(accumulate(x))

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

def summation(x):
    result = 0
    for i in range(x+1):
        result += i
    return result

expect = {}
for i in range(1, 1001):
    prob = 1 / float(i)
    expect[i] = summation(i) * prob

p_mapped = [expect[i] for i in p]

max = 0
for i in range(len(p_mapped)-2):
    answer = np.sum(p_mapped[i:i+3])
    if answer >= max:
        max = answer
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate

def main():
    
    # sys.stdin = open('input154d.txt')

    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    
    s = [0] + p
    s = list(accumulate(s))

    maxp = 0
    idx = 0
    for i in range(k, n):
      nowp = s[i] - s[i - k]
      if maxp < nowp:
        maxp = nowp
        idx = i

    # print(idx)

    sump = 0
    for j in range(idx-k + 1, idx+1):
      sump += p[j] * (p[j] + 1) / 2 / p[j]

    print(sump)
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

p_sum = [0] * (n + 1)

for i in range(n):
    p_sum[i] = p_sum[i - 1] + p[i]

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

ans = (ans + k) / 2
print(ans)

Submission status: Wrong Answer

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

# if n != k:
p = [0] * (n + 1)

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

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

ans = (ans + k) / 2
print(ans)
# else:
#    ans = (sum(p) + k) / 2
#    print(ans)

Submission status: Wrong Answer

Solution code:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

Max = sum(Input2[:Input1[1]])

for j in range(Input1[0]-Input1[1]):
    sum_ = Max-Input2[j]+Input2[j+Input1[1]]
    if Max  < sum_:
        Max = sum_
        
print(Max)