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:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

cemsum = [0]*(Input1[0])
Max = 0
for j in range(1,Input1[0]+1):
    cemsum[j-1] = sum(Input2[:j])

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

Submission status: Wrong Answer

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

import numpy as np

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

for i in range(n):
    #exps.append(sum(list(range(1, p[i]+1)))/p[i])
    exps.append((1+p[i])/2)

exps = np.array(exps)
cumexps = exps.cumsum()
np.insert(cumexps, 0, 0)

#print(exps)
#print(cumexps)

ans = -1
for i in range(n-k):
    tmp = -cumexps[i] + cumexps[i+k]
    if ans <= tmp:
        ans = tmp 

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().rstrip().split())
pi = list(map(int, sys.stdin.readline().rstrip().split()))
pi.sort()
pi = pi[::-1]
res = 0
for i in range(k):
    if pi[i] == 1:
        res += 1
    elif pi[i] % 2 == 0:
        res += pi[i] / 2 + 0.5
    else:
        res += pi[i] // 2 + 1
print(res)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().rstrip().split())
pi = list(map(int, sys.stdin.readline().rstrip().split()))
pi.sort()
pi = pi[::-1]
res = 0
for i in range(k):
    if pi[i] == 1:
        res += 1
    if pi[i] % 2 == 0:
        res += pi[i] / 2 + 0.5
    else:
        res += pi[i] // 2 + 1
print(res)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().rstrip().split())
pi = list(map(int, sys.stdin.readline().rstrip().split()))
pi.sort()
pi = pi[::-1]
res = 0
for i in range(k):
    if pi[i] % 2 == 0:
        res += pi[i] / 2 + 0.5
    else:
        res += pi[i] // 2 + 1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for n in range(0,N-K+1):
  sum_list=[]
  sum=0
  for i in range(n,n+K):
    sum+=(1+p[i])/2
    sum_list.append(sum)  
    
print(sum_list)
print(max(sum_list))

Submission status: Wrong Answer

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

K = A[1]
N = A[0]

P = list(map(float, input().split()))
P_list = P[K-1:N-1]

print(sum(list(map(lambda x: x / 2, P_list))))

Submission status: Wrong Answer

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

import numpy as np

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

for i in range(n):
    #exps.append(sum(list(range(1, p[i]+1)))/p[i])
    exps.append((1+p[i])/2)

exps = np.array(exps)
cumexps = exps.cumsum()

#print(exps)
#print(cumexps)

ans = -1
for i in range(n-k):
    tmp = -cumexps[i] + cumexps[i+k]
    if ans <= tmp:
        ans = tmp 

print(ans)

Submission status: Wrong Answer

Solution code:
A = input().split()
B = map(int, A)
C = list(B)
K = C[0]
N = C[1]

P = list(map(float, input().split()))
P_list = P[K-1:N-1]

print(sum(list(map(lambda x: x / 2, P_list))))

Submission status: Wrong Answer

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

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

s = [0]
a = 0
ans = 0

for i in range(n):
    c = 0
    a += p[i]
    s.append(a)
    #print(s)
    if i <= k - 1:
        continue
    else:
        c = a - s[i - k + 1]
        c += k
        #print(c)
        if c > ans:
            ans = c
        else:
            pass

print(ans / 2)

Submission status: Wrong Answer

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

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

s = []
a = 0
ans = 0

for i in range(n):
    c = 0
    a += p[i]
    s.append(a)
    
    if i <= k:
        continue
    else:
        c = a - s[i - k]
        c += k
        if c > ans:
            ans = c
        else:
            pass

print(ans / 2)

Submission status: Wrong Answer

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

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

s = []
a = 0
ans = 0

for i in range(n):
    c = 0
    a += p[i]
    s.append(a)
    
    if i <= k - 1:
        continue
    else:
        c = a - s[i - k]
        c += k
        if c > ans:
            ans = c
        else:
            pass

print(ans / 2)

Submission status: Wrong Answer

Solution code:
def kitaiti(number):
 return (1 + number)/2
def dp(mylist,K,N):
    i = 0
    count = sum(mylist[i:K + i])
    while K + i < N:
        i += 1
        if mylist[i -1] < mylist[i-1 + K]:
            count = sum(mylist[i:K + i])
    return count
N,K = (int(i) for i in input().split())
p = [int(x) for x in input().split()]
 
kitaiti = [kitaiti(x) for x in p]
 
print(dp(kitaiti,K,N))

Submission status: Wrong Answer

Solution code:
def kitaiti(number):
    count = 0
    for i in range(1,number + 1):
        count += (i / number)
    return count
def dp(mylist,K,N):
    i = 0
    count = sum(mylist[i:K + i])
    while K + i < N:
        i += 1
        if mylist[i -1] < mylist[i-1 + K]:
            count = sum(mylist[i:K + i])
    return count
N,K = (int(i) for i in input().split())
p = [int(x) for x in input().split()]

kitaiti = [kitaiti(x) for x in p]

print(dp(kitaiti,K,N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = tmp = 0
for i in range(n-k):
    tmp += p[i]-p[i+k]
    ans = max(ans, tmp)
print('{:.12f}'.format(ans))

Submission status: Wrong Answer

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

ans = 0
rdm = 0
for i in range(k):
    rdm = random.randrange(n)
    ans += p[rdm]
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
num = list(map(int, input().split()))
 
# 各サイコロの期待値を出す
expect = []
for i in range(N):
  expect.append((1 + num[i]) / 2)
  print(expect)
 
# 累積和を作る
cs = [0]
for (i, number) in enumerate(expect):
  cs.append(cs[i] + expect[i])

max = 0
for i in range(K, N+1): # 配列0番目に初期値0が増えてるので1足す
  if max < cs[i] - cs[i-K]:
    max = cs[i] - cs[i - K]
print(max)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
num = list(map(int, input().split()))
 
# 各サイコロの期待値を出す
expect = []
for i in range(N):
  expect.append((1 + num[i]) / 2)
  print(expect)
 
# 累積和を作る
cs = [0]
for i in range(N):
    cs.append(cs[i]+expect[i])
    print(cs)

max = 0
for i in range(K, N+1): # 配列0番目に初期値0が増えてるので1足す
  if max < cs[i] - cs[i-K]:
    max = cs[i] - cs[i - K]
print(max)

Submission status: Wrong Answer

Solution code:
buf=input().split(" ")
N=int(buf[0])
K=int(buf[1])
p=list(map(int, input().split()))
ex=[]

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

ex=sorted(ex,reverse=True)
print("{:.13f}".format(sum(ex[0:K])))

Submission status: Wrong Answer

Solution code:
buf=input().split(" ")
N=int(buf[0])
K=int(buf[1])
p=list(map(int, input().split()))
ex=[]

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

ex=sorted(ex,reverse=True)
print("{:.12f}".format(sum(ex[0:K])))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
sai = list(map(int,input().split()))
ka = z = 0
kk = k
sai = list(map(lambda x:(x+1)/2,sai))
for y in range(kk):
    z = sum(sai[y:y+kk])
    if z > ka:  
        ka = z
print(ka)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
sai = sorted(list(map(int,input().split())),reverse=True)
for x in range(len(sai)):
    sai[x] = ((sai[x]+1)*sai[x])/2/sai[x]

print(sum(sai[:k]))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

N, K = map(int, input().split())
p = list(map(int, input().split()))
exp = [0] + [(pi+1)/2 for pi in p]
exp = list(accumulate(exp))
ans = 0
for i in range(K+1, N+1):
    ans = max(ans, exp[i]-exp[i-K])
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * (n-k+1)
s_0 = sum(p[0:k])
s[0] = s_0
for i in range(n-k):
    s[i+1] = s_0 + p[k+i] - p[i]

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * (n-k+1)
s_0 = sum(p[0:k])
s[0] = s_0
for i in range(n-k-1):
    s[i+1] = s_0 + p[k+i+1] - p[i]

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(lambda x: (int(x)+1)/2, input().split()))

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_list = list(map(lambda x: (float(x) + 1) / 2, input().split()))

S_i = [0]
for i in range(n):
    S_i.append(S_i[i] + p_list[i])    

# print(S_i)
result_max = 0
for j in range(3, n+1):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_list = list(map(lambda x: (float(x) + 1) / 2, input().split()))

S_i = [0]
for i in range(n):
    S_i.append(S_i[i] + p_list[i])    

print(S_i)
result_max = 0
for j in range(3, n+1):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Submission status: Wrong Answer

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

S_i = []
S_i.append((p_list[0] + 1) / 2)

for i in range(1, n):
    S_i.append(S_i[i-1] + ((p_list[i] + 1) / 2))    

result_max = 0
for j in range(n):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Submission status: Wrong Answer

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

S_i = []
S_i.append((p_list[0] + 1) / 2)

for i in range(1, n):
    S_i.append(S_i[i-1] + ((p_list[i] + 1) / 2))    

result_max = 0
for j in range(n):
    cad_max = S_i[j] - S_i[j-k]
    result_max = max(cad_max, result_max)

print(result_max)

Submission status: Wrong Answer

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

S_i = []
S_i.append((p_list[0] + 1) / 2)

for i in range(1, n):
    S_i.append(S_i[i-1] + ((p_list[i] + 1) / 2))    

result_max = 0
for j in range(n-k):
    cad_max = S_i[j+k] - S_i[j]
    result_max = max(cad_max, result_max)

print(result_max)

Submission status: Wrong Answer

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

S_i = []
S_i.append((p_list[0] + 1) / 2)

for i in range(1, n):
    S_i.append(S_i[i-1] + ((p_list[i] + 1) / 2))    

result_max = 0
for j in range(n-k):
    cad_max = S_i[j+k] - S_i[j]
    if cad_max > result_max:
        result_max = cad_max

print(result_max)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [(int(x)+1)/2 for x in stdin.readline().rstrip().split()]
l = 0
r = len(P)
m = 0
res = []
res.append(P[0])
for i in range(len(P)-1):
    res.append(res[i] + P[i+1])

while(K < r):
    kitai = res[K] - res[l]
    if (kitai > m):
        m = kitai
    l +=1
    K +=1

print(m)

Submission status: Wrong Answer

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

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if N == 1 and K == 1:
    max_val = Ps_sum_list[-1]
    print(max_val)
elif N == K:
    max_val = Ps_sum_list[-1]
    print((max_val+K)/2)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Submission status: Wrong Answer

Solution code:
def f(x):
    return (x + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[:k])
for i in range(k, n):
    ans = max(ans, ans + p[i] - p[i - k])
print(ans)

Submission status: Wrong Answer

Solution code:
def f(x):
    return (x + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[:k])
for i in range(k, n):
    ans = max(ans, ans + p[i] - p[i - k])

Submission status: Wrong Answer

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

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if N == K:
    max_val = Ps_sum_list[-1]
    print(max_val)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Submission status: Wrong Answer

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

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if N == 0:
    print(0)
elif K == 0:
    print(0)
elif N == 1 and K == 1:
    max_val = max(Ps)
    print(max_val)
elif N <= K:
    max_val = Ps_sum_list[-1]
    print(max_val)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Submission status: Wrong Answer

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

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if N == 1 and K == 1:
    max_val = max(Ps)
    print(max_val)
elif N <= K:
    max_val = Ps_sum_list[-1]
    print(max_val)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K ] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
for i in range(N-K):
    val = Ps_sum_list[i+K] - Ps_sum_list[i]
    if val > max_val:
        max_val = val
print((max_val + K) / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def expect(n):
    res = (n + 1) / 2
    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())
list_p = [int(x) for x in input().split()]

total = sum(list_p[0:K])
max = total

for i in range(0,N-K+1) :
    total = total - list_p[i] + list_p[i+K-1]
    if total > max :
        max = total

print((max+K)/2)

Submission status: Wrong Answer

Solution code:
n , k = map(int, input().split())
p = list(map(int, input().split()))
p_accu = [p[0] + 1]

if k == 1:
    print( (max(p) + 1 ) / 2 )
    exit()

for i in range(1, n):
    p[i] += p[i-1] + 1
    p_accu.append(p[i])

S = p_accu[k-1]

for i in range(n - k):
    if S < p_accu[i+k] - p_accu[i]:
        S = p_accu[i+k] - p_accu[i]
    
print(S/2)

Submission status: Wrong Answer

Solution code:
n , k = map(int, input().split())
p = list(map(int, input().split()))
p_accu = [p[0] + 1]


for i in range(1, n):
    p[i] += p[i-1] + 1
    p_accu.append(p[i])

S = p_accu[k-1]

for i in range(n - k):
    if S < p_accu[i+k] - p_accu[i]:
        S = p_accu[i+k] - p_accu[i]
    
print(S/2)

Submission status: Wrong Answer

Solution code:
import sys

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

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

    sortp = sorted(p, reverse=True)

    sum = 0
    for i in range(k):
        sum += sortp[i] * (sortp[i] + 1) / 2 / sortp[i]
        
    print(sum)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n , k = map(int, input().split())
p = list(map(int, input().split()))
p_accu = [p[0] + 1]

for i in range(1, n):
    p[i] += p[i-1] + 1
    p_accu.append(p[i])

S = 0

for i in range(n - k):
    if S < p_accu[i+k] - p_accu[i]:
        S = p_accu[i+k] - p_accu[i]
    
print(S/2)

Submission status: Wrong Answer

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n ,k = i2()
p = intl()
def sx(n):
    return (n+1)/2

m = 0
pnt = 0
s = 0
for i in range(0,n-k+1):
    if i == 0:
        s = sum(p[i:i+k-1])
    else:
        s = s - p[i] + p[i+k-1]
    if s > m:
        m = s
        pnt = i
cnt = 0
for j in range(pnt,pnt+k):
    cnt += sx(p[j])
print(cnt)

Submission status: Wrong Answer

Solution code:
import array

def expect_value(number):
  expect = 0
  for i in range(1, number+1):
    expect = expect + i / number
  return expect
  
N, K = map(int, input().split())
num = list(map(int, input().split()))

# 各サイコロの期待値を出す
expect = []
for i in range(N):
  expect.append(expect_value(num[i]))

# 累積和を作る
cs = [0]
for (i, number) in enumerate(expect):
  cs.append(cs[i] + expect[i])

max = 0
for i in range(N, 0 + K, -1):
  if max < cs[i] - cs[i - K]:
    max = cs[i] - cs[i - K]
print(max)

Submission status: Wrong Answer

Solution code:
n, k = input().split()
n = int(n)
k = int(k)
p = list(map(int, input().split()))
if n==k:
	print((sum(p)+n)/n)
else:
	q = []
	for i in range(n):
		q.append(sum(p[:i+1]))
	r = []
	for i in range(n-k):
		r.append(q[i+k]-q[i])
	r.sort()
	print((r[n-k-1]+k)/2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
maxsumP = sum(P[0:K])
resP = P[0:K]
for i in range(N-K):
  mp = maxsumP - P[i] + P[K+i]
  if maxsumP < mp:
    resP = P[i+1:K+i+1]
    maxsumP = mp

res = 0
dp = {}
minp = min(resP)
psum = sum(range(minp+1))
dp[minp] = psum/minp
for i in range(minp+1, max(resP)+1):
  psum +=i
  dp[i] = psum/i

for p in resP:
  res += dp[p]
    
print(res)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p2 = [p[i]*0.5 + 0.5 for i in range(N)]
size = N + 1
cusum = [0] * size
max = 0

for i in range(1,N):
    cusum[i] = cusum[i-1] + p2[i]

for i in range(N-K+1):
    tmp = cusum[i+K] - cusum[i]
    if max < tmp:
        max = tmp
print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
kitaiti = []
for i in range(n):
  kitaiti.append((1+A[i])/2)
Sum = [0]+list(accumulate(kitaiti))
ans = 0
for i in range(n):
  if i+k<n:
    ans = max(ans,Sum[i+k]-Sum[i])
print(ans)

Submission status: Wrong Answer

Solution code:
def ext(k):
    if k%2 == 0:
        return ((k//2)+((k//2) + 1))/2
    else:
        return k//2 + 1

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

ans_list = p[:K]
S = sum(p[:K])
for i in range(N - K ):
    temp = S - p[i] + p[i + K]
    temp_list = p[i + 1:i + K + 1]
    if temp >= S:
        ans_list = temp_list
        S = temp

ans = sorted(ans_list)
A = K - 1 + ext(S - (K - 1))


print(A)

Submission status: Wrong Answer

Solution code:
def ext(k):
    if k%2 == 0:
        return ((k//2)+((k//2) + 1))/2
    else:
        return k//2 + 1

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

ans_list = p[:K]
S = sum(p[:K])
for i in range(N - K ):
    temp = S - p[i] + p[i + K]
    temp_list = p[i + 1:i + K + 1]
    if temp >= S:
        ans_list = temp_list
        S = temp

ans = sorted(ans_list)
A = 0

for a in ans:
    A += ext(a)


print(A)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
kitaiti = []
for i in range(n):
  kitaiti.append((1+A[i])/2)
Sum = list(accumulate(kitaiti))
ans = 0
for i in range(n):
  if i+k<n:
    ans = max(ans,Sum[i+k]-Sum[i])
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n,k = map(int,input().split())
A = [int(i) for i in input().split()]
kitaiti = []
for i in range(n):
  kitaiti.append((1+A[i])/2)
Sum = list(accumulate(kitaiti))
ans = 0
for i in range(1,n):
  if i+k<n:
    ans = max(ans,Sum[i+k]-Sum[i])
print(ans)

Submission status: Wrong Answer

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

Ary=[]
x=0
for p in P:
    x+=(p+1)/2
    Ary.append(x)
# print(Ary)
ans=Ary[K-1]-Ary[0]
buf,left,right=0,0,0
for i in range(1,N-K+1):
    left,right=i,left+K
    # print(left,right)
    buf=Ary[right]-Ary[left-1]
    if buf>ans:
        ans=buf
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
Ary=[]
a=0
for p in P:
    a+=(p+1)/2
    Ary.append(a)

left=0
ans=0
x=0
for right in range(K,N):
    x=Ary[right]-Ary[left]
    left+=1
    if ans<x:
        ans=x

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
def E(n):
  e=0
  for i in range(1,n+1):
    e+=i
  e = e/n
  return e

k=0
for i in range(N-K+1):
  l=sum(P[i:i+K])
  if l>k:
    k=l
    L=P[i:i+K]

A=0
for i in range(K):
  print(E(L[i]))
  A+=E(L[i])

print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np

a1 = input()
a2 = input()

list1 = np.array(list(map(int,a1.split(" "))))

list2 = (np.array(list(map(int,a2.split(" "))))*10+10)/2

res = 0
now = 0

k = list1[1]
n = list1[0]
i = 0
while i < n:
    now = now + list2[i]
    if i>k-1:
        now = now - list2[i-k]
        res = max(res,now)
    i = i + 1
print(res/10)

Submission status: Wrong Answer

Solution code:
import numpy as np

a1 = input()
a2 = input()

list1 = np.array(list(map(int,a1.split(" "))))

list2 = (np.array(list(map(int,a2.split(" "))))+1)/2

res = 0
now = 0

k = list1[1]
n = list1[0]
i = 0
while i < n:
    now = now + list2[i]
    if i>k-1:
        now = now - list2[i-k]
        res = max(res,now)
    i = i + 1
print(res)

Submission status: Wrong Answer

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

q = []
s = 0

for i in p:
    q.append((i+1)/2)
    if i == k:
        s = sum(q)
    elif i > k:
        q.pop(0)
        s = max(s, sum(q))
print(s)

Submission status: Wrong Answer

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

# cumulated value
c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = 0

for i in range(N - K):
    e = c_p[i + K] - c_p[i]
    if e > max_e:
        max_e = e

print((max_e + K) / 2)

Submission status: Wrong Answer

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

ma = 0
counter = 0
tmp = 0

for i in range(N):
    counter += 1
    tmp += (1+p[i])/2
    if counter > K:
        tmp -= (1+p[i-K])/2
        if ma < tmp:
            ma = tmp

print(ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = (int(nk) for nk in input().split())

prev_S = 0
curr_S = 0
count = 1
max_ev = 0
index = 0
has_eval_sk = False
zero_e = []
for p_str in input().split():
    e = (int(p_str)+1) / 2
    zero_e.append(e)
    if has_eval_sk:
        curr_S += e - zero_e[index]
        print(curr_S)
        max_ev = max(max_ev, curr_S)
        prev_S = curr_S
        index += 1
    else:
        curr_S += e
        if count == K:
            print(curr_S)
            prev_S = curr_S
            max_ev = curr_S
            has_eval_sk = True
        count += 1

print(max_ev)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
lis = list(map(int,input().split()))
total = 0

for i in range(m):
  total += lis[i]/2 + 0.5
ans = total

for k in range(m,n):
  total -= lis[k-4]/2 - lis[k]/2
  ans = max(ans,total)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
lis = list(map(int,input().split()))
total = 0

for i in range(m):
  total += lis[i]/2 + 0.5
ans = total

for k in range(m,n):
  total -= lis[k-4]/2 - lis[k]/2
  ans = max(ans,total)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
lis = list(map(int,input().split()))
total = 0

for i in range(m):
  total += lis[i] * 0.5 + 0.5
ans = total

for k in range(m,n):
  total -= lis[k-4]/2 - lis[k]/2
  ans = max(ans,total)
  
print(ans)

Submission status: Wrong Answer

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

def calc_expected_val(val):
    return (val*(1+val)/2)/val

def main():
    sort_P = sorted(P,reverse=True)
    max_sum_val = 0
    for i in range(K):
        max_sum_val += calc_expected_val(sort_P[i])
    
    print(max_sum_val)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = 0
for p in ps[-k:]:
    s += (p+1) / 2
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
count=0
cumsum=0
cumsumlist=[]
for i in p:
  cumsum+=i
  cumsumlist.append(cumsum)
gouke = cumsumlist[0]
for j in range(n-k):
  gouke = cumsumlist[j+k]-cumsumlist[j]
  count = max(gouke,count)
ans = (count+k)*0.5
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
count=0
cumsum=0
cumsumlist=[]
for i in p:
  cumsum+=i
  cumsumlist.append(cumsum)
gouke = cumsumlist[0]
for j in range(n-k):
  gouke = cumsumlist[j+k]-cumsumlist[j]
  if gouke>count:
    count=gouke
ans = (count+k)*0.5
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
count=0
cumsum=0
cumsumlist=[]
for i in p:
  cumsum+=i
  cumsumlist.append(cumsum)
gouke = cumsumlist[0]
for j in range(1,n-k):
  gouke = cumsumlist[j+k]-cumsumlist[j]
  if gouke>count:
    count=gouke
ans = (count+k)*0.5
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())#サイコロの個数、「隣接した」サイコロを振る数
p = list(map(float,input().split()))#さいころの目の最大値
judge = []
ans = 0
for i in range(n-k):
    expect = 0
    for j in range(k):
        expect += (p[i+j] + 1)/2
    if ans < expect:
        ans = expect
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())#サイコロの個数、振る数
p = sorted(list(map(float,input().split())),reverse=True)#さいころの目の最大値
ans = 0
for i in range(k):
    for j in range(int(p[i])):
        ans += (j+1)/p[i]
        print(p[i],j)
print(ans)

Submission status: Wrong Answer

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