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()))
current_best = 0
sum_list = [(1+p[0])/2]

if n == 1:
  print(sum_list[0])
  exit()
#累積和の計算
for i in range(n-1):
  sum_list.append(sum_list[-1]+(1+p[i+1])/2)

for j in range(n-k):
  expect = sum_list[j+k]-sum_list[j]
  if expect > current_best:
    current_best = expect
print(current_best)

Submission status: Wrong Answer

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

sum_list = []
sum_tmp = 0

init_tmp = 0
max_sum = init_tmp

for i in range(k):
	init_tmp += p_list[i]

tmp = init_tmp

for s in range(k, n):
	tmp = tmp + p_list[s] - p_list[s-k]

	if max_sum < tmp:
		max_sum = tmp


print((max_sum+k)/2)

Submission status: Wrong Answer

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

#累積和の計算
for i in range(n-1):
  sum_list.append(sum_list[-1]+(1+p[i+1])/2)

for j in range(n-k):
  expect = sum_list[j+k]-sum_list[j]
  if expect > current_best:
    current_best = expect
print(current_best)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = 0

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

Submission status: Wrong Answer

Solution code:
count = list(map(int,input().split()))
sort_li = list(map(int,input().split()))
total = 0

sort_li.sort(reverse = True)
for i in range(count[1]):
  a = 0
  for k in range(sort_li[i] + 1):
    a += k
  total = total + a / k
print(total)

Submission status: Wrong Answer

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

def cal_p(x):
    return x*(x+1)/2/x

tmp = []
ans = 0
for p in pl:
    tmp. append(cal_p(p))

for i in range(k, n):
    psum = sum(tmp[i+1-k:i+1])
    if psum > ans:
        ans = psum

print(ans)

Submission status: Wrong Answer

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

for i in range(n-k):
  expect = (sum(p[i:i+k])+k)/2
  if expect > current_best:
    current_best = expect

print(current_best)

Submission status: Wrong Answer

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

for i in range(N-K+1):
    total = sum(P[i:i+K])
    if total > max_total:
        ans = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))

print(ans)

Submission status: Wrong Answer

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

a = 0
for i in range(N - K + 1):
  if i == 0:
    f = i
    b = sum(p[0:K])
  else:
    b = a - p[i-1] + p[i + K - 1]
  
  if b > a:
    a = b
    f = i

ans = 0
for j in range(K):
  ans += (p[f + j] + 1) / 2

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
ans = 0
for i in range(n):
    p_list[i] = (1 + p_list[i]) / 2

wa = sum(p_list[0:k])

for j in range(n-k):
    wa = wa + p_list[j+k] - p_list[j]
    ans = max(ans, wa)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
p = [(int(i) + 1) * 0.5 for i in input().split()]
s = []
c = 0
for i in range(n):
    c += p[i]
    s.append(c)

m = 0
for i in range(k, n):
    m = max(m, s[i] - s[i-k])
print('{:.7f}'.format(m))

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * (N + 1)
    answer = 0
    for i in range(N):
        exceptation_sum[i] = p[i] + exceptation_sum[i - 1]
    for i in range(N - K + 1):
        answer = max(answer, exceptation_sum[i + K] - exceptation_sum[i])
    print(answer / 2 + K / 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * (N + 1)
    answer = 0
    for i in range(N):
        exceptation_sum[i] = (p[i] + 1) / 2 + exceptation_sum[i - 1]
    for i in range(N - K + 1):
        answer = max(answer, exceptation_sum[i + K] - exceptation_sum[i])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * N
    answer = 0
    for i in range(N):
        if not i == 0:
            exceptation_sum[i] = (p[i] + 1) / 2 + exceptation_sum[i - 1]
        else:
            exceptation_sum[i] = (p[i] + 1) / 2
    for i in range(1, N - K + 1):
        answer = max(answer, exceptation_sum[i + K - 1] - exceptation_sum[i - 1])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
S = [E for E in itertools.accumulate(P)]
ans = 0
for j in range(N-K):
    e = S[j+K]-S[j]
    if ans < e:
        ans = e
print(ans)

Submission status: Wrong Answer

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

exp_sum = []
sum_max = 0
exp1 = 0
for j in range(0,len(p)-k+1):
    sum_each = 0
    exp1 = 0
    sum1 = 0
    for i in range(j,j + k):
        sum1 += p[i]
        if sum1 >= sum_max:
            break
    if sum_max < sum1 or sum_max == 0:
        sum_max = sum1
        for i in range(j,j + k):
            sum_each = 0.5 * p[i] * (p[i] + 1)
            exp1 += sum_each/p[i]
        exp_sum.append(exp1)
print(max(exp_sum))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
*d,=list(map(int,input().split()))
 
def e(n):
    ex=(1+n)/2
    return ex
    
dex=[e(i) for i in d]

fst=0
for i in range(k):
    fst+=dex[i]

for i in range(n-k):
    x=fst-dex[i]+dex[i+k]
    fst=max(x,fst)
        
print(fst)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
*d,=list(map(int,input().split()))
 
def e(n):
    ex=(1+n)/2
    return ex
    
dex=[e(i) for i in d]

fst=0
for i in range(k):
    fst+=dex[i]

for i in range(n-k):
    x=fst-dex[i]+dex[i+k]
    if x>fst:
        fst=x
        
print(fst)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A = [p[0]]
for i in range(N-1):
	A.append(A[i] + p[i+1])

res = 0
for i in range(N - K):
	res = max(A[i + K] - A[i], res)
print( (res + K) / 2)

Submission status: Wrong Answer

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

#求める答えは入力をそれぞれ1足した数字の和を2で割ったものになる

#初項からk番目までの和
sum_1tok = 0
sum_k =[]
for i in range(k):
    sum_1tok += p[i]
sum_k.append(sum_1tok)
print(sum_k)

sum_max= 0
#ひとつずつずらしてリストに格納
for i in range(1,n-k+1):
    sum_k.append(sum_k[i-1] + p[k+i-1] - p[i-1])

print(sum_k)
#求める期待値に変換
ans = (max(sum_k) + k) /2
print(ans)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = [(i+1)/2 for i in B]
h = []
z = []
m = 0
for l in range(A[0]):
  m = m + k[l]
  h.append(m)
for l in range(A[1]-1, A[0]):
	x = h[l] - h[l-(A[1])]
	z.append(x)
print(max(z))

Submission status: Wrong Answer

Solution code:
# ウィンドウをスライドさせる際に，期待値の全体を再計算するのをやめた
N,K = map(int, input().split())
P = [int(i) for i in input().split()]

expect = (sum(P[0:K])+K)/2
ma = expect
for i in range(K,N):
  expect += (P[i]-P[i-K])/2
  print(expect, P[i],P[i-K])
  if ma < expect:
    ma = expect
print(ma)

Submission status: Wrong Answer

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

for i in range(n-k):
  k_sum = 0
  for j in range(k):
    k_sum += (p[i+j]+1)/2
  expect = k_sum
  if expect > current_best:
    current_best = expect

print(current_best)

Submission status: Wrong Answer

Solution code:
N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
e = sum(P[:K])
ans = e
for i in range(1, N-K):
    e = sum(P[i:i+K])
    if ans < e:
        ans = e
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = list(map(int, input().split()))
dice = list(map(int, input().split()))
sort_dice = sorted(dice, reverse=True)[:k]

sort_p = 1. / np.array(sort_dice)
sort = np.array([sum([j+1 for j in range(i)]) for i in sort_dice])
print(np.sum(sort_p * sort))

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
li = list(map(int, input().split()))
p = [0]*x
a = 0
ans = 0
for i in range(x):
    p[i] =  li[i]*(li[i]+1)//2/li[i]
    
a = sum(p[0:0+y])
for i in range(x-y):
    a = a-p[i]+p[i+y]
    ans = max(ans,a)    
print(ans)

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
li = list(map(int, input().split()))
p = [0]*x
a = 0
ans = 0
for i in range(x):
    p[i] =  li[i]*(li[i]+1)//2/li[i]
    
a = sum(p[0:0+y])
for i in range(1,x-y+1):
    a = a-p[i-1]+p[i+y-1]    
    ans = max(ans,a)
    
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()]
P_expect_sum = [0 for i in range(N)]

P_pred = 0
for i in range(N):
  P_expect = (1+P[i])/2
  P_expect_sum[i] = P_pred + P_expect
  P_pred = P_expect_sum[i]

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

Submission status: Wrong Answer

Solution code:
#ABC154C

n, k = list(map(int,input().split()))
p = [((int(x)+1)/2) for x in input().split()]

# ave = 0
# for i in range(n-k+1):
#     temp = p[i:i+k]
#     _ave = sum(temp)
#     if _ave>=ave:
#         ave = _ave
# print(ave)

ave = sum(p[0:k])
for i in range(n-k):
    _ave = ave-float(p[i])+ float(p[k+i])
    if _ave>=ave:
        ave = _ave
print(ave)

Submission status: Wrong Answer

Solution code:
N,K = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
P_expect_sum = [0 for i in range(N)]

for i in range(N):
  P_expect = (1+P[i])/2
  if i>0:
    P_expect_sum[i] += P_expect_sum[i-1] + P_expect
  else:
    P_expect_sum[i] = P_expect

ans = 0
if N != 1:
  for i in range(N-K):
    ans = max(ans, P_expect_sum[i+K] - P_expect_sum[i])
else:
  ans = P_expect_sum[0]
print(ans)

Submission status: Wrong Answer

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

sum_acc = [0]
tmp = 0
 
for i in range(n):
  tmp += (1 + p[i]) / 2
  sum_acc.append(tmp)

print(sum_acc)

ans = 0
for j in range(k, n + 1): 
  ans = max(sum_acc[j] - sum_acc[j - k], ans)

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()]
P_expect_sum = [0 for i in range(N)]

for i in range(len(P)):
  P_expect = ((1+P[i])*P[i]/2)/P[i]
  if i>0:
    P_expect_sum[i] += P_expect_sum[i-1] + P_expect
  else:
    P_expect_sum[0] = P_expect

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

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

max_index = 0
tmp_max = 0
dp = [0 for i in range(N)]

for i in range(N-K+1):
  if i == 0:
    for j in range(K):
      dp[i] += j
  else:
    dp[i] = dp[i-1] - P[i-1] + P[i+K-1]

  if tmp_max <= dp[i]:
    max_index = i

ans = 0
for i in range(max_index,max_index+K):
  ans += ((1+P[i])*P[i]/2)/P[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
 
p = list(map(int, input().split()))
 
p = [(e+1) / 2 for e in p]
 
s = sum(p[0:k])
s_max = 0

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

Submission status: Wrong Answer

Solution code:
#ABC154C

n, k = list(map(int,input().split()))
p = list(((int(x)+1)/2) for x in input().split())

ave = 0
j = 0

for i in range(n-k):
    temp = p[i:i+k]
    _ave = (sum(temp))
    if _ave>=ave:
        ave = _ave
print(ave)

Submission status: Wrong Answer

Solution code:
#ABC154C

n, k = list(map(int,input().split()))
p = list(((int(x)+1)/2) for x in input().split())

ave = 0
j = 0

for i in range(n-2):
    temp = p[i:i+k]
    _ave = (sum(temp))
    if _ave>=ave:
        ave = _ave
print(ave)

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
s_max = 0

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

Submission status: Wrong Answer

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

print(a/2+k/2)

Submission status: Wrong Answer

Solution code:
n, k, *p_n = map(int, open(0).read().split())
p_n.insert(0, 0)
for i in range(n):
    p_n[i + 1] = ((p_n[i + 1] + 1) / 2) + p_n[i]
    
p_n.insert(0, 0)

exp_sum = [0] * (n - k + 1)
for i in range(n - k + 1):
    exp_sum[i] = p_n[i + k] - p_n[i]
    
print(max(exp_sum))

Submission status: Wrong Answer

Solution code:
n, k, *p_n = map(int, open(0).read().split())

for i in range(n - 1):
    p_n[i + 1] = ((p_n[i + 1] + 1) / 2) + p_n[i]
    
p_n.insert(0, 0)

exp_sum = [0] * (n - k + 1)
for i in range(n - k + 1):
    exp_sum[i] = p_n[i + k] - p_n[i]
    
print(max(exp_sum))

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
n=s[0]
k=s[1]
s = list(map(int, input().split()))
ep=[]
for i in s:
    ep.append((1+i)/2)
s={}
s[k-1]=0
for i in range(k):
    s[k-1]+=ep[i]
for i in range(k-1,n-1):
    print(i)
    s[i+1]=s[i]+ep[i+1]-ep[i-k+1]
print(max(s.values()))

Submission status: Wrong Answer

Solution code:
def cal_expe(x):
  ret = (1 + x) / 2
  return ret

N,K = map(int, input().split())
data = [int(i) for i in input().split()]
sma = 0
for i in range(N):
  data[i] = cal_expe(data[i]) + sma
  sma = data[i]
max_score = data[K-1]
print(data)
for i in range(K-1,N):
  pro = data[i] - data[i-K]
  if pro > max_score:
    max_score = pro
print(max_score)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K-1):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
lis = []
for i in range(n):
    lis.append((p[i]+1)/2)

val = [0]
for i in range(1,n):
    val.append(val[i-1] + lis[i])
#print(val)

ans = val[k-1]
for i in range(k,n):
    if val[i] - val[i-k] > ans:
        ans = val[i] - val[i-k]
print(ans)

Submission status: Wrong Answer

Solution code:
def expected_value(k):
    k_sum=0
    for i in range(k):
        k_sum+=i+1
    return float(k_sum/k)

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

left=0
right=k
p_max=0
max_index=0
res=float(0)

while right<len(p):
    if p_max<sum(p[left:right]):
        max_index=left
    p_max=max(p_max,sum(p[left:right]))
    left+=1
    right+=1

p_max_list = p[max_index:max_index+k]

for p in p_max_list:
    res+=expected_value(p)

print(res)

Submission status: Wrong Answer

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

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

rui_kitai = [kitai[0]]

for i in range(1, n):
    ruiseki=rui_kitai[i-1]+kitai[i]
    rui_kitai.append(ruiseki)

gokei = 0

for i in range(n-k):
    if i==0:
        wa = rui_kitai[k-1]
    else:
        wa = rui_kitai[i+k-1]-rui_kitai[i-1]
    if gokei < wa:
        gokei = wa

print(gokei)

Submission status: Wrong Answer

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

S, T = list(map(int,(input().split())))
p = list(map(int,(input().split())))
ans = 0
anss = []
temp_sum= 0
sum_max = []
for i in range(T):
  ans = 0
  samp = p[i:T+i]
  for j in samp:
    ans += (1+j)/2
  anss.append(ans)  
 # if temp_sum < sum(samp):
 #   temp_sum = sum(samp)
 #   sum_max = samp
'''    
#print(sum_max)
for i in sum_max:
  x =(1+i)/2
  ans += x
'''

print(max(anss))

Submission status: Wrong Answer

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

S, T = list(map(int,(input().split())))
p = list(map(int,(input().split())))
ans = 0
anss = []
temp_sum= 0
sum_max = []
for i in range(T):
  ans = 0
  samp = p[i:T+i]
  if temp_sum < sum(samp):
    temp_sum = sum(samp)
    sum_max = samp
    
#print(sum_max)
for i in sum_max:
  x =(1+i)/2
  ans += x
  
print(ans)

Submission status: Wrong Answer

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

S, T = list(map(int,(input().split())))
p = list(map(int,(input().split())))
ans = 0
anss = []
temp_sum= 0
sum_max = []
for i in range(T):
  ans = 0
  samp = p[i:T+i]
  if temp_sum < sum(samp):
    temp_sum = sum(samp)
    sum_max = samp
    
#print(sum_max)
for i in sum_max:
  x =(list(range(1,i+1)))
  ans += sum(x)/len(x)
  
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

sum = 0
ans = 0
Q = deque([])
for i in range(n):
  Q.append(A[i])
  sum += A[i]
  if len(Q)==k:
    ans = max(ans, (sum+k)/2)
  sum -= Q.popleft()

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
P = [map(int,input().split())]
Q = []
R = P[K:]
s = 0
for i in Q:
    s += (i+1)/2
    Q.append((i+1)/2)
ans = s
for i in range(len(R)):
    s += (R[i] - Q[i])
    ans = max(s,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,k = LI()
p = LI()

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

l = [a(p[0])] + [0]*(n-1)
for i in range(1,n):
    l[i] = l[i-1] + a(p[i])
ans=0
for i in range(k,n):
    ans = max(ans,l[i]-l[i-k])

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.array([1 / float(i) for i in P])
# psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = ([(1 / float(i)) * ((1 / 2) * i * (i + 1)) for i in P])
# Emax = [] * (N - K + 1)

Ef = sum(E[N-K:-1])
for i in range(K):
    Emax = (sum(E[i:K + i]))
    if Emax > Ef:
        Ef = Emax
print(format(Ef, '.12f'))

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([1 / float(i) for i in P])
# psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = ([(1 / float(i)) * ((1 / 2) * i * (i + 1)) for i in P])
# Emax = [] * (N - K + 1)

Ef = sum(E[K-1:-1])
for i in range(K):
    Emax = (sum(E[i:K + i]))
    if Emax > Ef:
        Ef = Emax
print(format(Ef, '.12f'))

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([1 / float(i) for i in P])
# psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = ([(1 / float(i)) * ((1 / 2) * i * (i + 1)) for i in P])
# Emax = [] * (N - K + 1)

Ef = sum(E[K-1:-1])
for i in range(K):
    Emax = (sum(E[i:K + i]))
    if Emax < Ef:
        Ef = Emax
print(format(Ef, '.12f'))

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([1 / float(i) for i in P])
# psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = ([(1 / float(i)) * ((1 / 2) * i * (i + 1)) for i in P])
# E = p * psum
Emax = [] * (N - K + 1)
Emax[:] = [(sum(E[i:K + i])) for i in range(K)]
# [Emax.append(sum(E[i:K + i])) for i in range(K)]
print(max(Emax))

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([1 / float(i) for i in P])
# psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = ([(1 / float(i)) * ((1 / 2) * i * (i + 1)) for i in P])

# E = p * psum
Emax = []
[Emax.append(sum(E[i:K + i])) for i in range(K)]
print(max(Emax))

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([1 / float(i) for i in P])
psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = p * psum
Emax = []
# for i in range(K):
#     Emax.append(sum(E[i:K + i]))

[Emax.append(sum(E[i:K + i])) for i in range(K)]
print(max(Emax))

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([1 / float(i) for i in P])
psum = np.array([(1 / 2) * i * (i + 1) for i in P])
E = p * psum
Emax = []
for i in range(K):
    Emax.append(sum(E[i:K + i]))
print(max(Emax))

Submission status: Wrong Answer

Solution code:
# D - Dice in Line
from itertools import accumulate


def main():
    N, K, *P = map(int, open(0).read().split())
    # cumsum[i] = cumulative sum of expected values in [0, i]
    cumsum = tuple(accumulate(i * (1 + i) / (2 * i) for i in P))
    ans = 0
    for i in range(N - K):
        ans = max(ans, cumsum[i + K] - cumsum[i])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

p = sorted(p, reverse=True)

def divid(x):
  return (x / 2) + 0.5

print(sum(list(map(divid, p[:k]))))

Submission status: Wrong Answer

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

res_max = 0
for i in range(N-K+1):
    res = sum(p[i:i+K])
    if res > res_max:
        i_max = i

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
    A[i]+=1

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

ans=0.0

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

if n==k==1:
    ans=A[0]

print(ans/2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
    A[i]=(A[i]+1)/2

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

ans=0.0
for i in range(n-k):
    now=A[i+k]-A[i]
    if now>ans:
        ans=now
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

cml_sum = deque([(P[0]+1)/2.0])
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
    A[i]=(A[i]+1)/2
A.sort()
A.reverse()
ans=0.0
for i in range(k):
    ans+=A[i]
print(ans)

Submission status: Wrong Answer

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

def calcE(l):
  expect = 0
  for i in range(len(l)):
    expect += ( (l[i]*(l[i]+1) / 2 ) / l[i] )
  return expect

maxl = list()
for j in range(n-k+1):
  if sum(P[j:j+4]) > sum(maxl):
    maxl = P[j:j+4]

print(calcE(maxl))

Submission status: Wrong Answer

Solution code:
import numpy as np

N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
P = np.cumsum(P)
M = 0
#print(P)
for i in range(N-K):
  #print(P[i+K],P[i])
  if M < P[i+K]-P[i]:
    M = P[i+K]-P[i]
print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
lst = [int(x)+1 for x in input().split()]
a = 0
for i in range(N-K+1):
    if sum(lst[-1*K:]) > a:
        a = sum(lst[-1*K:])
        lst.pop()

print(a/2)

Submission status: Wrong Answer

Solution code:
N, K = 4,1
li = [6,6,6,6]
r = []
ans = []
for x in li:
    r += [(x-1)*(1/2)+1]
    ans += [sum(r[-K:])]
print(max(ans))

Submission status: Wrong Answer

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
wa = sum(p[0:k])
for i in range(n-k):
    num = wa - p[i] + p[i+k]
    if num > wa:
        wa = num
print(0.5*(wa+k))

Submission status: Wrong Answer

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

li = []
ans = 0

for i in range(len(p)):
    p[i] += 1
    li.append(p[i])
    if len(li) < k:
        continue
    elif len(li) == k:
        print(li)
        max = sum(li)
        buf = max
    elif len(li) > k:
        print(li)
        tmp = buf - li[0] + li[-1]
        buf = tmp
        if tmp >= max:
            max = tmp
        del li[0]

print(max/2)

Submission status: Wrong Answer

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

scope_index = 0
max_sum = 0
for i in range(k):
    max_sum += p_list[i]

now_sum = max_sum
for p_i in range(k, len(p_list)):
    now_sum -= p_list[p_i - k]
    now_sum += p_list[p_i]

    if max_sum < now_sum:
        scope_index = p_i
        max_sum = now_sum

# ex = (max_sum+k)/2
# print(ex)

max_scope_list = p_list[scope_index - k + 1:scope_index+1]
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:
from itertools import accumulate
N,K = map(int, input().split())
answer = list(map(lambda x: (1+x)/2, list(map(int, input().split()))))
total = 0
tmp = list(accumulate(answer))
for i in range(1,N-K+1):
    diff = tmp[i]-tmp[i-K]
    total = max(total,diff)
print(total)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
lst = [int(x)+1 for x in input().split()]
lst.sort()

E = (sum(lst[-1*K:]))/2
print(E)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N,K = map(int, input().split())
answer = list(map(lambda x: (1+x)/2, list(map(int, input().split()))))
total = 0
tmp = list(accumulate(answer))
for i in range(K,N):
    diff = tmp[i]-tmp[i-K]
    total = max(total,diff)
print(total)

Submission status: Wrong Answer

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

window = sum(A[0:K])
max_s = 0
for i in range(N - K):
    window -= A[i]
    window += A[i + K]
    if window > max_s:
        max_s = window
print((max_s+K) / 2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
expp = [(i + 1) / 2 for i in p]
cumu, cumu_expp = 0, []
for i in expp:
    cumu += i
    cumu_expp.append(cumu)

max_expp = 0
for i in range(n - k):
    sumpk = cumu_expp[i + k] - cumu_expp[i]
    if max_expp < sumpk:
        max_expp = sumpk
print(max_expp)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
c=s[1]
d=0
a=sum(t[0:c])
b=0
for j in range(s[0]-1):
  if j==0:
    b=sum(t[0:c])
    continue
  else:
    a+=(t[j+1]-t[j-1])
    b=max(b,a)
b+=s[1]
print(b/2)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N,K = map(int, input().split())
answer = list(map(lambda x: (1+x)/2, list(map(int, input().split()))))
tmp = list(accumulate(answer))
total = 0
for i in range(N-K):
    total = max(total,tmp[i+K]-tmp[i])
print(total)

Submission status: Wrong Answer

Solution code:
N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
E = [sum(P[:i]) for i in range(1,N+1)]
m = 0
for i in range(N-K):
  if m < E[i+K]-E[i]:
    m= E[i+K]-E[i]
print(m)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = sum(P[0:K])
for i in range(K, N):
    total = tmp-P[i-K]+P[i]
    if tmp < total:
        index = i-K+1
    tmp = total
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)

Submission status: Wrong Answer

Solution code:
N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
#S = [sum(P[:i+1]) for i in range(N)]

m = sum(P[:3])

for i in range(N-K+1):
  if m < sum(P[:i+K])-sum(P[:i]):
    m= sum(P[:i+K])-sum(P[:i])
print(m)

Submission status: Wrong Answer

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

res = 0
for i in range(k):
  res += (A[i]+1)/2

print(res)

Submission status: Wrong Answer

Solution code:
n,k,*p=map(int,open(0).read().split())
s=m=k
for i in range(k,n):s+=p[i]-p[i-k]*(i>=k);m=max(m,s)
print(m/2)