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().strip().split())
p = list(map(int, input().strip().split()))

e = []

for i in range(n):
  a = p[i] * (p[i] + 1) / 2
  e.append(a/p[i])

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

Submission status: Wrong Answer

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

for i in range(0, N-K+1):
    for j in range(i, i+K):
        temp += p[j]
    if max_val < temp:
        max_val = temp
        index = i
print(index)
sum_value = 0

for i in range(index, index+K):
    sum_value += (p[i]+1) / 2
print(sum_value)

Submission status: Wrong Answer

Solution code:
input_s = [input() for i in range(2)]
n, k = list(map(int,input_s[0].split()))
p_list= list(map(int,input_s[1].split()))
q_list = [(x + 1) / 2 for x in p_list]
print(max(["{:.7f}".format(sum(q_list[x:x+k])) for x in range(n - k + 1)]))

Submission status: Wrong Answer

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


def expect(n):
    res = 0
    for i in range(1, n+1):
        res += i
    res /= n
    return res

ans_sum = sum(p[:k])
idx = 0
for i in range(k, n):
    tmp_sum = ans_sum + p[i] - p[i-k]
    if tmp_sum > ans_sum:
        ans_sum = tmp_sum
        idx = i

ans = list(map(expect, p[idx-k+1:idx+1]))
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ps = list(map(int, input().split()))
dic = {}
Es = []
for i in range(N):
  if not ps[i] in dic.keys():
    p = sum(range(1, ps[i]+1))/ps[i]
    dic[ps[i]] = p
  else:
    p = dic[ps[i]]
  Es.append(p)
  if i<(K-1):
    continue
  elif i==(K-1):
    max_e = sum(Es)
  else:
    p_old = Es.pop(0)
    if p_old<p:
      max_e += (p-p_old)
print(max_e)

Submission status: Wrong Answer

Solution code:
def sgm(i):
    sum=0
    for j in range(i+1):
        sum+=j
    return sum

n, k=map(int, input().split())
p=list(map(int, input().split()))
p.sort(reverse=True)
e=0
for i in range(k):
    e+=(sgm(p[i])/p[i])
print(e)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

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

    loop=n-k+1

    ms=0
    bef=0
    for i in range(loop):
        tmp=0
        if i < k:
            for j in range(k):
                tmp+=p[i+j]/2+1/2
            if tmp > ms:
                ms = tmp
        else:
            tmp=bef
            tmp-=(p[i-1]/2+1/2)
            tmp+=(p[i+k-1]/2+1/2)

    print(ms)

    return

resolve()

Submission status: Wrong Answer

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

for i in range(len(P_list)):
    P_list[i] = int(P_list[i]) / 2 + 0.5

tmp = sum(P_list[0:K])
ans = 0

for j in range(len(P_list) - K):
    ans = max(ans, tmp - P_list[j] + P_list[j + K])
    tmp = tmp - P_list[j] + P_list[j + K]

print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[0 for _ in range(n-k+1)]
q=sum(p[:k])
s[0]=q
m=q
f=0
for i in range(1,n-k+1):
  q=q-p[i-1]+p[i-1+k]
  s[i]=q
  if q>m:
    f=i
    m=q
ans=0
for i in range(f,f+k):
  ans+=(p[i]+1)/2






print(ans,s,f)

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []

def calc_expected(pi):
    out = 0
    for i in range(1, pi+1):
        out += i
    out = out / pi
    return out

max = 0
tmp = 0
for i in range(N):
    pi = int(input_arr[i])
    ex = calc_expected(pi)
    arr.append(ex)
    tmp += ex
    if(i >= K-1):
        if(max <= tmp):
            max = tmp
        try:
            tmp -= arr[i-K-2]
        except:
            pass
print(max)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

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

e = []
for i in p:
    e.append(1+i)

l = 0
s = sum(e[:k-1])
for i in range(n-k):
    tmp = s + e[i+k] - e[i]
    if tmp > s:
        s = tmp
        l = i + 1

print(sum(e[l:l+k])/2)

Submission status: Wrong Answer

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

dice_array2 = sorted(dice_array, reverse=True)
sum = 0
for i in range(tar):
  cnt = 0
  for j in range(1, dice_array2[i]+1):
    cnt += j
  sum += (cnt / dice_array2[i])
  
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import sys
import numpy as np
from collections import deque
from itertools import combinations
sys.setrecursionlimit(10**9)



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

    sum_0 = 0
    for i in range(K):
        sum_0 += p[i]


    sum_n = sum_0
    max = sum_0
    print(sum_n)
    for i in range(N-K): # i+1
        sum_n = sum_n + p[i+K] - p[i]
        print(sum_n)
        if max < sum_n:
            max = sum_n

    ans = (K + max) / 2
    print("{0:.20f}".format(ans))

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

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

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

l = 0
s = sum(e[:k-1])
for i in range(n-k):
    tmp = s + e[i+k] - e[i]
    if tmp > s:
        s = tmp
        l = i + 1

print(sum(e[l:l+k]))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N, K = map(int,input().split())
P = list(map(int, input().split()))
Ans = sum(P[0:K])+K
Ans_max = Ans

for i in range(N-K-1):
    A = P[i]
    B = P[i+K] 
    Ans = Ans+B-A
    if B > A:
        Ans_max = max(Ans_max, Ans)
    
print(Ans/2)

Submission status: Wrong Answer

Solution code:
def kitai(p):	
  return (1+p)/2
 
def main():
  n,k = map(int, input().split())
  p = [int(x) for x in input().split()]
  
  res = 0
  
  for i in range(n-k):
    a = 0
    for j in range(k):
      a += kitai(p[i+j])
    if(a>res):
      res = a
  print(res)
  
  return 0
          
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

s = [0] * len(p)
s[0] = ((p[0]*(p[0]+1)) // 2) /p[0]
p[0] = ((p[0]*(p[0]+1)) // 2) /p[0]
for i in range(1, len(p)) :
    s[i] = s[i-1] + ((p[i]*(p[i]+1)) // 2) /p[i]
    p[i] = ((p[i]*(p[i]+1)) // 2) /p[i]

#print(p)
#print(s)
maxValue = -100100100
anker = -99

if k != 1 :
    for i in range(n-k+1) :
        if maxValue < s[i+k-1] - s[i] :
            maxValue = s[i+k-1] - s[i]
            anker = i
    ans = 0
    for i in range(anker, anker+k) :
        ans += p[i]
        #print(ans)

    print(ans)

if k == 1 :
    print(max(p))

Submission status: Wrong Answer

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

print(sum(p[0:k])/2+0.5*k)

Submission status: Wrong Answer

Solution code:
from decimal import *
n, k = map(int, input().split())
p = list(map(int, input().split()))
ho_list = [0] * n

for j in range(0, n):
    ho_list[j] = (p[j] + 1) / 2

sum_list = [0] * n
sum_list[0] = ho_list[0]
for i in range(1, n):
    sum_list[i] = sum_list[i - 1] + ho_list[i]
ans = 0
for i in range(k - 1, n):
    ans = max(ans, sum_list[i] - sum_list[i - k])
print("{:.12f}".format(ans))

Submission status: Wrong Answer

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

num_sum = 0

max_pair = (0, k-1)
for i in range(k):
    num_sum += p[i]
max_sum = num_sum

for i in range(k, len(p)):
    num_sum -= p[i-k-1]
    num_sum += p[i]
    # print(num_sum, i-k+1,i)
    if num_sum > max_sum:
        max_sum = num_sum
        max_pair = (i-k+1, i)
avg = 0
for i in range(max_pair[0], max_pair[1]+1):
    num = p[i]
    num_sum = round(num *(num+1)/(2*num), 10)
    avg += num_sum
print(avg)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
###########　入力
# 整数の入力
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

maxSum = 0  #最大出目の合計値　の最大値
maxSumPoint = 0
maxExp = 0

for i in range(0, N-K+1):
    exp = 0
    for j in range(K):
        exp += p[i+j]
    if exp > maxSum:
        maxSum = exp
        maxSumPoint = i

print(maxSumPoint)

for i in range(maxSumPoint, maxSumPoint+K):
    maxExp += (p[i]+1)/2    #個別の期待値
###########　出力
print(maxExp)

Submission status: Wrong Answer

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

memo = [0] * (n + 1)

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

ans = 0
for i in range(k, n):
    ans = max(ans, memo[i] - memo[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()))
ans= 0
tmp=0
for i in range(n-k):
    if sum(p[i:i+k])>tmp:
        tmp = sum(p[i:i+k])
        ans= i
anss=0
for j in p[ans:ans+k]:
    anss+=(j+1)/2


print(anss)

Submission status: Wrong Answer

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

s = sum(p[0:k])
m = 0
pos = 0
for i in range(n - k + 1):
    s = s - p[i] + p[i+k-1]
    if m < s:
        m = s
        pos = i
r = 0
for i in range(k):
    v = p[pos + i]
    s = 0
    for j in range(1, v + 1):
        s += j
    r += s/v
print(r)

Submission status: Wrong Answer

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

def estim(n):
    return float(0.5*(n+1))

for i in range(N-K+1):
    ans=0
    for j in  range(i,i+K):
        temp=0
        temp+=(estim(p[j]))
        if ans <temp:
            ans=temp
print(temp)

Submission status: Wrong Answer

Solution code:


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

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

expt=list(map(expct,p))

#print(expt[1:k])

maxval=sum(expt[1:k])

for i in range(2,n-k+1):
  curval=sum(expt[i:i+k])
#  print(maxval,curval)
  if curval>maxval:
    maxval=curval

print(maxval)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def kitai(p):	
  return (1+p)/2

def main():
  n,k = map(int, input().split())
  p = [int(x) for x in input().split()]
  
  res = 0
  
  for i in range(n-k):
    a = 0
    for j in range(k):
      a += kitai(p[i+j])
    if(a>res):
      res = a
  print(res)
  
  return 0
          
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
dp = [0]*N
dp[0] = sum(p[:K])
for i in range(1, N-K):
    dp[i] = dp[i-1] - p[i-1] + p[i+K-1]
index = dp.index(max(dp))
for i in range(index, index+K):
    ans += 0.5*p[i]*(p[i]+1)/p[i]
print(ans)

Submission status: Wrong Answer

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

num_sum = 0

max_pair = (0, k-1)
for i in range(k):
    num_sum += p[i]
max_sum = num_sum

for i in range(k, len(p)):
    num_sum -= p[i-k-1]
    num_sum += p[i]
    # print(num_sum, i-k+1,i)
    if num_sum > max_sum:
        max_sum = num_sum
        max_pair = (i-k+1, i)
avg = 0
for i in range(max_pair[0], max_pair[1]+1):
    num = p[i]
    num_sum = round(num *(num+1)/(2*num), 7)
    avg += num_sum
print(avg)

Submission status: Wrong Answer

Solution code:
n, k = (int(x) for x in input().split())
p = list(int(x) for x in input().split())

max_val = 0
for i in range(0, len(p)-k+1):
  tmp = p[i:i+k]
  val = 0
  for t in tmp:
    val += sum([x for x in range(t+1)]) / t
  if max_val < val:
    max_val = val

print(val)

Submission status: Wrong Answer

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

def E(x):
    z=1/x*(1+x)*x/2
    return z
p.sort(reverse=True)
c=0
for i in range(K):
    z=E(p[i])
    c+=z
print(c)

Submission status: Wrong Answer

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

M = [sum(P[:K]) / 2 + K / 2]

for i in range(1, N-K+1):
    M.append(M[i-1] - P[i-1]/2 + P[i]/2)


print(max(M))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

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

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

l = 0
s = sum(e[:k-1])
for i in range(n-k):
    tmp = s + e[i+k] - e[i]
    if tmp > s:
        s = tmp
        l = i + 1

print(sum(e[l:l+k]))

Submission status: Wrong Answer

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

ans = 0 # MAX_K
for i in range(K):
  temp = p_list[i]
  
ans = temp
for i in range(K,N):
  temp = temp - p_list[i-1] + p_list[i]
  if ans < temp:
    ans = temp

print( (ans + K) /2 )

Submission status: Wrong Answer

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

dice_array2 = sorted(dice_array, reverse=True)
sum = 0
for i in range(tar):
  cnt = 0
  for j in range(dice_array2[i]):
    cnt += j
  sum += (cnt / dice_array2[i])
  
print(sum)

Submission status: Wrong Answer

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

answer = []
for i in range(0,N):
    ev = sum(range(1,p[i]+1))/p[i]
    answer.append(ev)

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
result_list = []
for i in range(n-k+1):
  p_part = p_list[i:i+k]
  sum_p = sum(p_part)
  result = (sum_p + k)//2
  result_list.append(result)
print(max(result_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n , k = map(int, input().split())
a = list(int(i) for i in input().split())

temp = sum(a[0:k])
max_  = temp
for i in range(n-k):
  f = a[i]
  s = a[i+k]
  temp -= f
  temp += s
  if f <= s:
    max_ = temp
    
print((max_+k)/2)

Submission status: Wrong Answer

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

for i in range(0, N-K):
    for j in range(i, i+K):
        temp += p[j]
    if max_val < temp:
        max_val = temp
        index = i

sum_value = 0

for i in range(index, index+K):
    sum_value += (p[i]+1) / 2
print(sum_value)

Submission status: Wrong Answer

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))

SS = {sum(B[i:i+A[1]]):B[i:i+A[1]] for i in range(len(B)-A[1]+1)}
tes = 0
for i in range(len(max(SS.values()))):
    dice = list(range(1,max(SS.values())[i]+1))
    ex = 0
    p = 1/len(dice)
    for x in dice:
        px = p*x
        ex += px

    tes += ex
print(tes)

Submission status: Wrong Answer

Solution code:
c,d=map(int,input().split())
a=[int(x) for x in input().split()]
b=a.index(max(a))
b1=[]
b2=[]
for i in range(d):
    b1.append(a[b+i])
    if b+i==len(a)-1:
        break
for i in range(d):
    b2.append(a[b-i])
    if b-i==0:
        break
c1=max(b1,b2)
tot=0
for i in c1:
    for _ in range(1,i+1):
        tot+=_*1/i
print(tot)

Submission status: Wrong Answer

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

print(sum(p[0:k])/k+1)

Submission status: Wrong Answer

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

ind = 0
temp, maxA = sum(P[:K]), sum(P[:K])
sumA = [temp]
#print(range(K,N))
for i in range(K,N) :
    temp = temp-P[i-K]+P[i] 
#    print(temp)
    if temp > maxA:
        ind = i
#print(ind)

sol=0
for j in range(ind-K+1,ind+1) :
    sol += (P[j]+1)/2 
print(float(sol))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(lambda x: int(x) * (int(x)+1) // 2 / int(x), input().split()))
print(p)
prev = sum(p[0:k])
sum_max = prev
for i in range(n-k+1):
    if i == 0:
        tmp = prev
    else:
        tmp = prev - p[i-1] + p[i+k-1]

    sum_max = max(sum_max, tmp)
    prev = tmp

print(sum_max)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=map(int,input().split())
p=list(map(int,input().split()))
p=np.array(list(map(lambda x: (1+x)/2, p)))
mx_0 = np.sum(p[:K])
mx=0
#print(p)
for i in range(1,N-K+1):
  #print(p)
  #print(p[i-1],p[i+K-1])
  s = mx_0-p[i-1]+p[i+K-1]
  mx_0=s
  #print(s)
  mx = max(s,mx)
  
print(mx)

Submission status: Wrong Answer

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

sum_memo = [0]*1001
x_memo = [0] * 1001
x_list = [0]*N

for i in range(1,1001):
    sum_memo[i] = sum_memo[i-1] + i

for i in range(N):
    if x_memo[p[i]] == 0:
        x_memo[p[i]] = sum_memo[p[i]]/p[i]
    x_list[i] = x_memo[p[i]]


ans = 0
tmp = sum(x_list[:K])
for l in range(N-K):
    r = l+K
    tmp = tmp -  x_list[l] + x_list[r]
    ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
at = l[0]
ans = 0
max_i = 0
max_l = sum(l[:k])
hikaku = sum(l[:k])
if k == 1:
    a = max(l)
    print(a * (a + 1) / 2 / a)
else:
    for i in range(1, n - k + 1):
        hikaku = hikaku - at + l[i + k - 1]
        if max_l < hikaku:
            max_i = i
            max_l = hikaku
    for i in range(k):
        a = l[max_i + i]
        ans += a * (a + 1) / 2 / a
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,K=map(int,input().split())
P=list(map(int,input().split()))


num=0
S=0
ans=0

for i in range(K):
    num=P[i]
    S=P[i]*(P[i]+1)//2
    ans+=S/num
A=[ans]
for i in range(N-K):
    m=(P[i]*(P[i]+1)//2)/P[i]
    a=(P[i+K]*(P[i+K]+1)//2)/P[i+K]
    ans-=m
    ans+=a
    A.append(ans)
ans=A[0]
for i in range(1,N-K+1):
    if A[i]>ans:
        ans=A[i]
print(A)
print(ans)

Submission status: Wrong Answer

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

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



max = 0
for j in range(n - k):
    sum_k = P_ave_sum[j + k] - P_ave_sum[j]
    if sum_k > max:
        max = sum_k

print(max)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
 
a = [0]*(N-K+1)
f = sum(p[:K])
a[0] = f

for i in range(N-K):
    f = f + p[i+K] - p[i]
    a[i+1] = f
##print(a)
num = 0

for i in range(1,N-K+1):
    if a[i] > a[i-1]:
        num = i
ans = 0
##print(num)
##print(p[num:num+K])

for i in range(num,num+K):
    ans += (p[i]+1)/2

print(ans)

Submission status: Wrong Answer

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

idx = 0
m = sum(p[:k])
for i in range(k, n):
    if m < m + p[i] - p[i-k]:
        m = m + p[i] - p[i-k]
        idx = i-k+1

ans = 0
for n in p[idx:idx+k]:
    ans += (n + 1) * 0.5
print('{:.7f}'.format(float(ans)))

Submission status: Wrong Answer

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

ans = 0
exv = 0

for j in range(k):
    exv += (ls[j] + 1) / 2

for i in range(k, n):
    exv += (ls[i] + 1) / 2
    exv -= (ls[i - k] + 1) / 2
    
    if exv > ans:
        ans = exv

print(ans)

Submission status: Wrong Answer

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

array = []
index = 0

for i in range(len(P)-K+1):
    if sum(P[i:i+K]) >= index:
        index = sum(P[i:i+K])
        array = P[i:i+K]


sum_array = {}
array = sorted(array)

index = 0
for j in range(1, array[0]+1):
    index += j
sum_array[array[0]] = index


for i in range(len(array)-1):
    index = sum_array[array[i]]
    for j in range(array[i]+1, array[i+1]+1):
        index += j

    sum_array[array[i+1]] = index


ans = 0

for k, v in sum_array.items():
    ans += v / k


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num = sum(P[0:K])
ls = P[0:K]
ans = [0]*K
for i in range(N-K+1):
    if num < sum(P[i:i+K]):
        ls = P[i:i+K]
for j in range(K):
    ans[j]=(ls[j]+1)*ls[j]/(2*ls[j])
print(sum(ans))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
tmp = sum(l[:k])
for i in range(k,n):
  tmp += l[i]-l[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()))

s = [0] * len(p)
s[0] = ((p[0]*(p[0]+1)) // 2) /p[0]
p[0] = ((p[0]*(p[0]+1)) // 2) /p[0]
for i in range(1, len(p)) :
    s[i] = s[i-1] + ((p[i]*(p[i]+1)) // 2) /p[i]
    p[i] = ((p[i]*(p[i]+1)) // 2) /p[i]

#print(p)
#print(s)
maxValue = -100100100
anker = -99

for i in range(n-k+1) :
    if k == 1 :
        if maxValue < s[i] :
            maxValue = s[i]
            anker = i
    if maxValue < s[i+k-1] - s[i] :
        maxValue = s[i+k-1] - s[i]
        anker = i

ans = 0
for i in range(anker, anker+k) :
    ans += p[i]
    #print(ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ps = list(map(int, input().split()))
Es = []
for i in range(N):
  p = sum(range(1, ps[i]+1))/ps[i]
  Es.append(p)
  if i<(K-1):
    continue
  elif i==(K-1):
    max_e = sum(Es)
  else:
    if Es.pop(0)<p:
      max_e = sum(Es)
print(max_e)

Submission status: Wrong Answer

Solution code:

import sys
import numpy as np
from collections import deque
from itertools import combinations
sys.setrecursionlimit(10**9)


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

    sum_0 = 0
    for i in range(K):
        sum_0 += p[i]


    sum_n = sum_0
    max = sum_0
    print(sum_n)
    for i in range(N-K): # i+1
        sum_n = sum_n + p[i+K] - p[i]
        print(sum_n)
        if max < sum_n:
            max = sum_n

    ans = (K + max) / 2
    print(ans)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nk = input()

po = input()

N = int(nk.split(' ')[0])
K = int(nk.split(' ')[1])

p = po.split(' ')
p2 = [(int(i) + 1 )/2 for i in p]


tes = 0
maxv = 0
for i in list(range(N-K + 1)):# 連続するKこの選び方のパターン
    tes = 0
    for j in range(0,K-1):
        tes += p2[i+j]
    
    # print(tes)
    if (tes > maxv):
        maxv = tes

# print('max',maxv)
print(maxv)

Submission status: Wrong Answer

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

n, k = int(n), int(k)

ans = 0
c = 0

for i in range(n - k + 1):
    for j in range(k):
        c += p[i + j]
    c += k
    if c >= ans:
        ans = c


print(ans / 2)

Submission status: Wrong Answer

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    N, K = map(int, f_i.readline().split())
    p = tuple(map(int, f_i.readline().split()))
    
    idx = 0
    max_s = sum(p[:K])
    s = max_s
    for i, t in enumerate(zip(p[1:], p[K:]), start=1):
        pi, pj = t
        s += (pj - pi)
        if s > max_s:
            max_s = s
            idx = i
    
    ans = (sum(p[idx:idx+K]) + K) / 2
    
    print(ans)

solve()

Submission status: Wrong Answer

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

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

l = 0
s = sum(e[:k-1])
for i in range(n-k):
    tmp = s + e[i+k] - e[i]
    if tmp > s:
        s = tmp
        l = i + 1

print(sum(e[l:l+k]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

convolved = np.convolve(expected_vals, np.ones(k))

print(convolved)
print(max(convolved))

Submission status: Wrong Answer

Solution code:
def K(n):
    s = 0
    for i in range(1, n+1):
        s += i
    return s / i

def d():
    n, k = input().split()
    n = int(n)
    k = int(k)
    p = input().split()
    m = 0
    for i in range(0, n-k+1):
        m2 = 0
        for i2 in range(0, k):
            m2 += K(int(p[i+i2]))
        if m < m2:
            m = m2
    return m2
print(d())

Submission status: Wrong Answer

Solution code:
#import re
import sys
#input = sys.stdin.readline
#import heapq
#import bisect
from collections import deque
#import math

def main():
    n, k = map(int, input().split())
    P = list(map(int,input().split()))
    d = deque()
    tmpans = 0
    ans = 0
    for i in range(k):
        tmpans += (P[i]+1)/2.0
        d.append(P[i])

    for i in range(k,n):
        com = d.popleft()
        into = P[i]
        d.append(into)
        tmpans = tmpans + (into - com)/2
        if ans < tmpans: ans = tmpans
    print(ans)
    
    


    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = 0
for n in range(N-K):
    tmp = 0
    for i in range(K):
        V[n+i] = (0.5*Pn[n+i]*(Pn[n+i]+1))/Pn[n+i]
        tmp += V[n+i]
    ans = max(ans, tmp)

print(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]=(1+p[i])/2
cs=[]
sum=0
for i in range(n):
	sum+=p[i]
	cs.append(sum)
ans=0
for i in range(n-k+1):
	ans=max(ans,cs[i+k-1]-cs[i-1])
print('{:.8f}'.format(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations

def expectval(num):
    up = [n for n in range(1, num+1)]
    return sum(up) / num

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

ans = -1
for comb in combinations(l, k):
    _sum = sum(map(expectval, comb))
    if _sum > ans:
        ans = _sum

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

Submission status: Wrong Answer

Solution code:
import itertools
n, k = map(int, input().split())
p = list(map(int, input().split()))
ki = [0]*1001
for i in range(1, 1001):
    ki[i] = ki[i-1]+i

pp = []
for pa in p:
    pp.append(ki[pa]/pa)

# print(pp)
ppp = list(itertools.accumulate(pp))
# print(ppp)
ans = 0
for i in range(1, n-k+1):
    ans = max(ans, ppp[i+k-1]-ppp[i-1])

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

Submission status: Wrong Answer

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


print(anss)

Submission status: Wrong Answer

Solution code:
def sumA(n):
	return n*(n+1)//2

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

s = [0 for i in range(k)]
ans = 0
mm = 0
m = 0
j = 0
for i in range(n):
  if j < k:
    s[j] = sumA(p[i])/p[i]
    mm+=s[j]
  else:
    mm-=s[j%k]
    mm+= sumA(p[i])/p[i]
    if ans < mm:
      ans = mm
    s[j%k] = sumA(p[i])/p[i]
  j+=1
print(ans)

Submission status: Wrong Answer

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

def calc_ev(l):
    ev = 0
    for p in l:
        ev += 0.5 * (p + 1)
    return ev


frst_idx = 0
MAX = 0
for i in range(N - K):
    ev = calc_ev(p[i : i + K])
    MAX = max(MAX, ev)
print(MAX)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    answer = 0
    p_max = 0
    p_max_index = 0
    for i in range(N):
        if p_max < p[i]:
            p_max = p[i]
            p_max_index = i
    for i in range(max(p_max_index - K + 1, 0), min(p_max_index + K - 1, N - K)):
        exceptation = 0
        for j in p[i:i + K]:
            exceptation += (1 + j) // 2
        answer = max(answer, exceptation)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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