Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Wrong Answer

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



cumsum = []
cumsum_diff = 0
for i in range(N):
    if i == 0:
        cumsum.append((p[i] + 1)/2)
    else:
        cumsum.append(cumsum[i - 1] +( p[i] + 1)/2)

# print(cumsum)

for i in range(N - K + 1):
    if i <= N - K:
        if cumsum_diff < cumsum[i + K - 1] - cumsum[i-1]:
            cumsum_diff = cumsum[i + K - 1] - cumsum[i-1]

print(cumsum_diff)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
L = list(map(int,input().split()))
 
aaa = sum(L[0:k])
ans = aaa
i = 0
while i < n-k-1:
    aaa += L[i+k]
    aaa -= L[i]
    if ans <= aaa:
        ans = aaa
    i += 1    
     
print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))
# 1 - pi
p_cumsum = np.cumsum(p)

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

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

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p = list(map(int, input().split()))
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=e
for i in range(1,N-(K)):
  smax=s[i+K]-s[i]
  e=(K+smax)/2

  max_e = max(max_e, e)

print(max_e)

Submission status: Wrong Answer

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

num_li = [0]*n
ans = 0.0
num = 0.0

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

num = sum(num_li[:k])

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
#模範解答の通りにやってみる
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
if K==1:
	print((max(P)+1)/2)
elif N==K:
	print((sum(P)+N)/2)
else:
	for k in range(1,N+1):
		S.append(sum(P[0:k]))
	T=[S[K-1]]
	for n in range(0,N-K-1):
		T.append(S[n+K]-S[n])
	print((max(T)+K)/2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()

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

Submission status: Wrong Answer

Solution code:
def resolve_D():
    max_ = 0
    res = 0
    n, k = map(int, input().split())
    l = list(map(int, input().split()))
    for i in range(0, n-k+1):
        total = sum(l[i:i+k])
        if total > max_:
            max_ = total
            max_i = i
    for j in l[max_i:max_i+k]:
        res += j * (j + 1) / 2 / j
    print(res)

Submission status: Wrong Answer

Solution code:
def expected_value(arr):
    print(arr)
    return ([sum(range(1, ele+1)) / ele for ele in arr])

n, k = [int(x) for x in input().split()]
arr = list(map(int,input().split()))
sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
print(expected_value(arr[max_i:max_i + k]))
print(sum(expected_value(arr[max_i:max_i + k])))

Submission status: Wrong Answer

Solution code:
#模範解答の通りにやってみる
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
for k in range(1,N+1):
    S.append(sum(P[0:k]))
T=[S[K-1]]
for n in range(0,N-K-1):
    T.append(S[n+K]-S[n])
print((max(T)+K)/2)

Submission status: Wrong Answer

Solution code:
def expected_value(arr):
    return ([sum(range(1, ele )) / ele for ele in arr])

n, k = [int(x) for x in input().split()]
arr = list(map(int,input().split()))
sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
print(expected_value(arr[max_i:max_i + k]))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d = tuple(map(int, input().split()))
e = [0]*n

for i in range(n):
    s = (1+d[i])*d[i]/2
    e[i] = s / d[i]
print(1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = input().split()
bubun = [0 for i in range(N)]
sums= [0 for i in range(N+K)]
E=0
S=0

for i in range(N):
    p[i] = int(p[i])
    

X=N-K+1
sums[0] = p[0]
for i in range(N-1):
    sums[i+1] = sums[i] + p[i+1]

for i in range(N):
    bubun[i] = sums[i+K]-sums[i]

for i in range(N):

    if bubun[i] > S:
        S = bubun[i]


E=(S+K)/2

print(E)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
P_List=list(map(int,input().split()))
#print(N,K)
#print(P_List)

def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    #print(p,result)
    return result

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

kitaichi_list=[]
ruisekiwa_list=[]
ruisekiwa=0
for a in range(N):
    kitaichi_list.append(Kitaichi2(P_List[a]))
    ruisekiwa += Kitaichi2(P_List[a])
    ruisekiwa_list.append(ruisekiwa)

#print(kitaichi_list)
#print(ruisekiwa_list)
pre_max=0
temp_max=0
max_num=0
for j in range(N-K):
    temp_max = ruisekiwa_list[j+K] - ruisekiwa_list[j]
    

    if pre_max < temp_max:
        pre_max = temp_max
    temp_max=0

print(pre_max)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 1
if N == K:
    print((sum(ilist)+K)/2)
else:
    while True:
        if i == N-K+1:
            break
        else:
            s = max_dice - ilist[i-1] + ilist[i+K-1]
            if s > max_dice:
                max_dice = s
                ind = i
            i += 1
    max_p = (sum(ilist[ind:ind+K])+K)/2
    print(max_p)

Submission status: Wrong Answer

Solution code:
# def get_start_end(p, start, end):



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

ans_max = 0

max_num = 0
max_index = 0
for i in range(n):
    if(max_num < p[i]):
        max_num = p[i]
        max_index = i

start_index = max_index
last_index = max_index
flag = False
count = 0
for i in range(k - 1):
    if(last_index == n - 1):
        start_index -= 1
        last_index -= count
        count = 0
    elif(start_index == 0):
        last_index += 1
        start_index += count
        count = 0
    else:
        if(p[start_index - 1] > p[last_index + 1]):
            start_index -= 1
            last_index -= count
            count = 0
        elif(p[start_index - 1] < p[last_index + 1]):
            last_index += 1
            start_index += count
            count = 0
        else:
            start_index -= 1
            last_index += 1
            count += 1

if(count > 0):
    if(last_index == n - 1):
        last_index -= count
    else:
        start_index += count


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

print(ans)

Submission status: Wrong Answer

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

total = 0
L = []

for i in range(K):
  m = P[i]
  total += (m + 1) / 2
  
print(total)

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int, input().split())
    A = list(map(int,input().split()))
    P=[0]*N
    for i in range(N):
        P[i]=(A[i]+1)/2
    max=0
    check=0
            
    #for j in range(K):
    #    check +=P[j]
    check = sum(P[0:K])
    #print(check)
    for i in range(K,N):
        check = check+P[i]-P[i-K]
        #print(i)
        #print(check)
        if check > max:
            max=check
    print(max)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    
    csum = [sum(p[:i]) for i in range(1,K+1)]
    #esum = [0]*(N-K+1)
    ans = 0
    for i in range(N-K):
        csum.append(csum[-1]+p[i+K])
        #esum[i] = csum[-1] - csum[i]
        esum = csum[-1] - csum[i]
        if ans < esum : ans =esum
    print(  (ans+K)*0.5  )
    return

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
P=[(int(i)+1)/2 for i in input().split()]
p=np.cumsum(P)
MAX=sum(P[0:k])

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

Submission status: Wrong Answer

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

p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

max_e=0
for i in range(N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    
    csum = [sum(p[:i]) for i in range(1,K+1)]
    esum = [0]*(N-K+1)
    for i in range(N-K):
        csum.append(csum[-1]+p[i+K])
        esum[i] = csum[-1] - csum[i]
    print(  (max(esum)+K)*0.5  )
    return

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

dice = list(map(int, input().split()))
a = 0
b = 0

a = sum(dice[0: k])
b = sum(dice[0: k])

res = 0
ll = 0
s = 0
mmm = range(k, len(dice))
for i in mmm:
    a += dice[i]
    a -= dice[s]
    if a > b:
        b = a
        ll = i
    s += 1

res = (sum(dice[ll- k + 1: ll + 1]) + k) /2

print(res)

Submission status: Wrong Answer

Solution code:
N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  expected_list.append((int(p[i])+1)/2)
anan = 0
for j in range(K):
  anan += expected_list[j]
max_list.append(anan)
for i in range(N):
  anan = 0
  try:
    anan = max_list[i-1]-int(p[i-1])+int(p[i+K-1])
  except:
    pass
  max_list.append(anan)
  
print(max(max_list))

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int, input().split())
    A = list(map(int,input().split()))
    P=[0]*N
    for i in range(N):
        P[i]=(A[i]+1)/2
    max=0
    check=0
            
    for j in range(K):
        check +=P[j]
    #print(check)
    for i in range(K,N):
        check = check+P[i]-P[i-K]
        #print(i)
        #print(check)
        if check > max:
            max=check
    print(max)
main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))
# 1 - pi
ans = n - k
init = p[0]
for i in range(k, n):
    # print(i)
    if init < p[i]:
        init = p[i-k]
        ans = i
# print(ans)
exp = 0
for i in range(ans - k + 1, ans + 1):
    exp += p[i]
print('{:.12f}'.format(exp))

Submission status: Wrong Answer

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

num_li = [0]*n
ans = 0.0
num = 0.0

for i in range(n):
    num_li[i] = ((p[i]*(p[i]+1))/2)/(p[i])

num = sum(num_li[:k])

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num,ans)

print(ans)

Submission status: Wrong Answer

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

import numpy as np

E = (np.array(P)+1)/2
E = np.cumsum(E)  

ans = 0.0
for i in range(0,N-K):
  ans = max(ans, E[i+K]-E[i])
print(float(ans))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A=list(map(int, input().split()))  
 
num = sum(A[0:K])
ind = 0
max_num =0
for i in range(N-K):
    if A[i] < A[i+K]:
        num = sum(A[i:i+K])
        if num> max_num:
            ind = i+1
            max_num = num
 
ans = 0
for i in range(ind,ind+K):
    ans += (1+A[i])/2

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0
Sum = 0
a = np.array(a)
a = a*0.5 + 0.5
ans = []

if d == 1:
  print(max(a))
elif n == d:
  print(sum(a))
else:
  for i in range(n-d+1):
    left = a[i]
    right = a[i+d-1]

    if i == 0:
      Sum = sum(a[i:i+d])
      Max = sum(a[i:i+d])
      ans = a[i:i+d]
    else:
      Sum = Sum + right - left

      if Sum >= Max:
        Max = Sum
        ans = a[i:i+d]
      else:
        pass

  print(sum(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))
p += 1
sum_e = np.cumsum(p)
ans = -1
for i in range(n-k):
    ans = max(ans, sum_e[i+k] - sum_e[i])
print(ans/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=0
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=(1+j)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))
p += 1
sum_e = np.cumsum(p)
ans = 0
for i in range(n-k):
    ans = max(ans, sum_e[i+k] - sum_e[i])
print(ans/2)

Submission status: Wrong Answer

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

##for i in range(max(P)):
##    ans.append(((i+1)(i+2)/2)(i+1))
##print(ans)
for i in range(N+1-K):
    ans.append(sum(P[i:i+K]))
ansidx = ans.index(max(ans))
for j in range(K):
    ans1.append((P[ansidx+j]*(P[ansidx+j]+1)/2)/P[ansidx+j])
sum(ans1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0
Sum = 0
a = np.array(a)
a = a*0.5 + 0.5
ans = []

if d == 1:
  ans1 = max(a)
  print(ans1*0.5 + 0.5)
elif n == d:
  ans = np.array(a)
  ans = ans*0.5 + 0.5
  print(sum(ans))
else:
  for i in range(n-d+1):
    left = a[i]
    right = a[i+d-1]

    if i == 0:
      Sum = sum(a[i:i+d])
      Max = sum(a[i:i+d])
      ans = a[i:i+d]
    else:
      Sum = Sum + right - left

      if Sum >= Max:
        Max = Sum
        ans = a[i:i+d]
      else:
        pass

  print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 1
if N == K:
    print((sum(ilist)+K)/2)
else:
    while True:
        s = max_dice - ilist[i-1] + ilist[i+K-1]
        if s > max_dice:
            max_dice = s
            ind = i
        if i == N-K:
            break
        else:
            i += 1
    max_p = (sum(ilist[ind:ind+K])+K)/2
    print(max_p)

Submission status: Wrong Answer

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

for i in range(n - k):
    if p_list[i] < p_list[i + k]:
        index = i + 1

for i in range(k):
    value += (1 + p_list[index + i])/ 2 

print(value)

Submission status: Wrong Answer

Solution code:
# def get_start_end(p, start, end):



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

ans_max = 0

max_num = 0
max_index = 0
for i in range(n):
    if(max_num < p[i]):
        max_num = p[i]
        max_index = i

start_index = max_index
last_index = max_index
flag = False
for i in range(k - 1):
    if(last_index == n - 1):
        start_index -= 1
    elif(start_index == 0):
        last_index += 1
    else:
        if(p[start_index - 1] > p[last_index + 1]):
            start_index -= 1
        elif(p[start_index - 1] < p[last_index + 1]):
            last_index += 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map( int, input().split())
    P = list(input().split())
    max_num = 0
    
    for i in range(N-K+1):
        sum_num = sum(int(P[j]) for j in range(i,i+K))
        if sum_num>max_num:
            tmp = i

    sum_exp = sum((float(P[j])+1)/2 for j in range(tmp,tmp+K))
    print(sum_exp)
        

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
max_l = 0
Max_l = p[0:K]
S = [0]
s=0
for j in range(N):
    s += p[j]
    S.append(s)

for i in range(N-K+1):
    m = S[K+i]-S[i]
    if m > max_l:
        max_l = m



print((max_l+K)//2)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
s = []
t = 0
for i in range(n):
    t +=p[i]
    s.append(t)

for i in range(n-k):
    x = s[i+k]-s[i]
    if x > ans:
        ans = x

print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sum = 0
ans = 0

for i in range(a[0]):
    sum += (1 + b[i])/2
    if i > a[1]-1:
        sum -= (1 + b[i-a[1]])/2
        if ans < sum:
            ans = sum

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = input().split()
ex = [0 for i in range(N)]
bubun = [0 for i in range(N-K+1)]
sums= [0 for i in range(N)]
E=0
S=0

for i in range(N):
    p[i] = int(p[i])
    

X=N-K+1
sums[0] = p[0]
for i in range(N-1):
    sums[i+1] = sums[i] + p[i+1]

for i in range(X-1):
    bubun[i] = sums[i+K]-sums[i]

for i in range(X):

    if bubun[i] > S:
        S = bubun[i]


E=(S+K)/2

print(E)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
max_l = 0
Max_l = p[0:K]
S = [0]
s=0
for j in range(N):
    s += p[j]
    S.append(s)

for i in range(N-K+1):
    m = S[K+i]-S[i]
    if m > max_l:
        max_l = m
        Max_l = p[i:i+K]



print((sum(Max_l)+K)//2)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
for j in range(0, k-1):
  p[j]=(p[j]+1)*p[j]/(p[j]*2)#p[i]が期待値になった
list00=[]
for i in range(k-1, n):
  p[i]=(p[i]+1)*p[i]/(p[i]*2)#p[i]が期待値になった
  list00.append(sum(p[i-k+1:i+1]))
list00.sort()
print(list00)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nk = input().split()
tmp = input().split()
n = int(nk[0])
k = int(nk[1])

hai = [0]*n
max = 0

for i in range(n):
  hai[i] = (sum(range(int(tmp[i])))+int(tmp[i]))/int(tmp[i])
  if k<=i:
   for j in range(k):
    t = sum(hai[(i-j):(i+k-j)])
    if max < t :
       max = t
print(max)

Submission status: Wrong Answer

Solution code:
s = input().split()
n = int(s[0])
k = int(s[1])

p_n = input().split()

up_to = n - k

result = 0.0

for i in range(n):
    p_n[i] = (1 + int(p_n[i]))/2

sum_ex = 0.0

for i in range(k):
    sum_ex += p_n[i]

hozo = -10000
delta = 0
for i in range(up_to):
    delta += p_n[i+k] - p_n[i] 
    if(hozo < delta):
        hozo = delta


result = hozo + sum_ex
print('{0:.6f}'.format(result))

Submission status: Wrong Answer

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

P_ex=list(map(lambda x: (x+1)/2,P))


for i in range(0,K):
    
    zantei+=P_ex[i]
zanans=0
buffer=P_ex[0]
for i in range(1,N-K+1):
    if(zantei-buffer+P_ex[K+i-1]>zantei):
        zantei+=(P_ex[K+i-1]-buffer)
    buffer=P_ex[i]

print(zantei)

Submission status: Wrong Answer

Solution code:
import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = list(itertools.accumulate(A))
    
    if A[0] == 1 and len(A) == 1:
        return 1
    
    ans = 0
    for i in range(M, N):
        ans = max(ans, l[i] - l[i-M])
    
    ans = (ans+1) / 2
    
    return ans

print(solve())

Submission status: Wrong Answer

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

ind = K-1
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))
print('{:.7f}'.format(sol))

Submission status: Wrong Answer

Solution code:
def solve(_list,_k):
  _sum = -1
  tmp = sum(_list[:_k])
  for i in range(len(_list)-_k):
    s = tmp + _list[i+_k] - _list[i]
    if _sum < s:
      _sum = s
    tmp = s

  ans = (_sum+_k) / 2
  return ans


if __name__ == "__main__":
  _n, _k = map(int, input().split())
  _l = [int(i) for i in input().split()]

  result = solve(_l, _k)
  print(result)

Submission status: Wrong Answer

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

def hoge(n):
  return ( 1.0 + n ) / 2.0 / n

for i in range(0,len(P)-k+1):
  num = 0
  for j in range(i , i+k):
    num = num + hoge(P[j])
  if mx < num:
    mx = num

print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = list(map(int, input().split()))

Ex = []

size = N-K+1 

current_max_sum = 0

for i in range(size):
  S = s[i:K+i]
  sum_list = sum(s[i:K+i])
  if sum_list > current_max_sum:
    current_max_sum = sum_list
    Ex = []
    for n in range(K):
      me = 0
      for q in range(S[n]+1):
        me += q
    Ex.append(me/S[n])

print(sum(Ex))

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sum = 0
ans = 0
be = 0

for i in range(a[0]):
    sum += (1 + b[i])/2
    if i > a[1]-1:
        sum -= (1 + b[i-a[1]])/2
        if ans < sum:
            ans = sum

print(ans)

Submission status: Wrong Answer

Solution code:
# 入力
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans_list = []

for i in range(n - k + 1):
    p_t = []
    for i in range(i + k):
        p_t.append(p[i])
    # 1個あたりの期待値
    p_all = sum(p_t)
    p_e = 0
    for p_ in p_t:
        p_e += p_ * (1 / p_all)
    ans = p_e * len(p_t)
    ans_list.append(p_e)

# 期待値*個数
ans = max(ans_list)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = list()
C = 0
for i in range(N):
  k = sum(range(1, A[i]+1))/A[i]
  B.append(k)
for j in range(N-K+1):
  c = sum(B[j:j+K])
  if C <= c:
    C = c
    print(C)
print(C)

Submission status: Wrong Answer

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

#ABC153D


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


tmp = []
for i in range(k):
	tmp.append(p[i])

x = 0
y = tmp
for i in range(k, n):
	t = tmp[0]
	tmp.append(p[i])
	tmp.pop(0)
	if t < p[i]:
		y = tmp		

ans = 0
for i in y:
	a = 0
	if i % 2 == 0:
		a = (i*i+i)/2
	else:
		b = int(i/2)
		a = b*2 + 1 + b*i
	ans += a / i

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
for j in range(0, k-1):
  p[j]=(p[j]+1)*p[j]/(p[j]*2)#p[i]が期待値になった
list00=[]
for i in range(k-1, n):
  p[i]=(p[i]+1)*p[i]/(p[i]*2)#p[i]が期待値になった
  list00.append(sum(p[i-k-1:i]))
list00.sort()
print(list00[n-k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K > 1:
    max_p = max(p)
    max_p_index = p.index(max_p)
    # print(max_p_index)
    p = p[max_p_index - (K - 1): max_p_index + (K - 1)]

sum_l = 0
sum_p = 0
sum_p_len = []
max = 0

for i in range(len(p) - K + 1):
    l = p[i:K]
    sum_l = sum(l)
    if max < sum_l:
        max = sum(l)
        sum_p_len = l
    K += 1

# print(sum_p_len)

sum = 0

for i in sum_p_len:
    for j in range(i):
        j += 1
        sum += j / i
    sum_p += sum
    sum = 0

print(sum_p)

Submission status: Wrong Answer

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

cnt=0
s=sum(p[0:k])
for i in range(n-k):
    tmp = s-p[i]+p[i+k]
    if s < tmp:
        cnt = i+1
        s = tmp

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

print(ans)

Submission status: Wrong Answer

Solution code:

# N個のサイコロ。隣接するK個のサイコロを選んで振る
N, K = map(int, input().split())
#
# 左から i 番目のサイコロは 1 から pi までの pi 種類の目がそれぞれ等確率で出る
P = list(map(int, input().split()))

max_list = []
is_first = True
for i in range(K, N+1):
    if is_first:
        max_list = P[i-K:i]
        is_first = False
    else:
        new_list = P[max(i - K, 0):i]
        if P[i-K] > max_list[0]:
            max_list = new_list
            max_num = sum(max_list)

result = 0
for n in max_list:
    result += sum([n for n in range(1, n+1)]) / n

print(result)

Submission status: Wrong Answer

Solution code:
import math

# 入力、宣言
N,K=map(int,input().split())
intList=list(map(int,input().split()))
Intsum=0

result=0

# 処理
# 一番右のさいころから逆算して期待値を算出
for i in range(len(intList)-1,len(intList)-K-1,-1):
    Intsum=intList[i]*(1+intList[i])/2
    result+=Intsum/(intList[i])

# 出力
print(result)

Submission status: Wrong Answer

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

sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
ans = 0
for j in arr[max_i:max_i+k]:
  ans += sum(range(1, j+1)) / j
  print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
l = [(int(i)+1)/2 for i in input().split()]
l.append(0)
temp = sum(l[:b])
max = 0
for i in range(b,a+1):
  temp = temp + l[i] - l[i-b]
  if max < temp:
    max = temp
    
print(max)

Submission status: Wrong Answer

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

limit_sum = sum(sorted(p_list, reverse=True)[:3])
average_sum = sum(p_list)/len(p_list)

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        if average_sum < p_list[p_i + i]:
            now_sum=0
            break
        now_sum += p_list[p_i + i]

    if limit_sum == now_sum:
        max_sum = now_sum
        scope_index = p_i
        break

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = p_list[scope_index:scope_index + k]
ex = 0
for scope in max_scope_list:
    for num in range(1, scope+1):
        ex += num*1/scope
print(ex)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))
# 1 - pi
ans = n - k
init = p[0]
for i in range(k, n):
    # print(i)
    if init < p[i]:
        init = p[i]
        ans = i
# print(ans)
exp = 0
for i in range(ans - k + 1, ans + 1):
    exp += p[i]
print('{:.12f}'.format(exp))

Submission status: Wrong Answer

Solution code:
import math
 
n,k = map(int, input().split())
l = input().split()
maxim = 0
dmaxim = 0
maxp = 0
for i in range(k):
  maxim += int(l[i])
dmaxim = maxim
for i in range(n-k):
  dmaxim += int(l[i+k])
  dmaxim -= int(l[i])
  if(dmaxim >= maxim):
    maxim = dmaxim
    maxp = i
mmm = 0
for i in range(k):
  mmm += (int(l[i])*(int(l[i])+1))/(2*int(l[i]))
print(mmm)

Submission status: Wrong Answer

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

#print(Pi)
indMax = Pi.index(max(Pi))

MX = sum(Pi[indMax-1:indMax+K-1])
  
ans= (MX + K)/2
print(ans)
#n/2(n+1) / n = 1/2 (n+1)

#1/2 (n+1)
#KN + K

Submission status: Wrong Answer

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

P_ex=list(map(lambda x: (x+1)/2,P))


for i in range(0,K):
    
    zantei+=P_ex[i]
zanans=0
buffer=P_ex[0]
for i in range(1,N-K+1):
    if(P_ex[K+i-1]>buffer):
        zantei+=(P_ex[K+i-1]-buffer)
    buffer=P_ex[i]

print(zantei)

Submission status: Wrong Answer

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

limit_sum = sum(sorted(p_list, reverse=True)[:3])
average_sum = sum(p_list)/len(p_list)

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        if average_sum < p_list[p_i + i]:
            break
        now_sum += p_list[p_i + i]

    if limit_sum == now_sum:
        max_sum = now_sum
        scope_index = p_i
        break

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = p_list[scope_index:scope_index + k]
ex = 0
for scope in max_scope_list:
    for num in range(1, scope+1):
        ex += num*1/scope
print(ex)