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 = list(map(str,input().split()))
P = list(map(int, input().split()))
K=int(K)

ans=0
for i in range(len(P)-K):
    tmp_ans=sum(P[i+1:i+K+1])
    # print(tmp_ans)
    if ans<tmp_ans:
        ans=tmp_ans
        # print(ans)
        # print(K)

print((ans+K)/2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*k
for i in range(n):
    if i<k:
        a[i]=p[i]
    else:
        if p[i]>a[0]:
            a.remove(a[0])
            a.append(p[i])
print((sum(a)+k)*0.5)

Submission status: Wrong Answer

Solution code:
# D

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

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

ans = (ans+K)/2

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
X=0
for k in range(K):
	X+=P[k]

for n in range(1,N-K+1):
	#if P[n-1]<P[n+K-1]:
	#	X=X+P[n+K-1]-P[n-1]
	#	maxn=n
	X=max(X,X+P[n+K-1]-P[n-1])
	#print(n,n+K-1,(X+P[n+K-1]-P[n-1])/2)

print((X+K)/2)

##15 20 10 13=>58
##

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
e=list(map(int,input().split()))
m=max(e)
arr=[]

for i in range(n-k+1):
  tmp=e[i:i+k]
  if m in tmp:
    arr.append((sum(tmp)+k)/2)

print(max(arr))

Submission status: Wrong Answer

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

E = []
for i in range(N):
    E.append(0)
    for j in range(P[i]):
        E[i] += (j+1) / P[i]
print(E)
E.sort(reverse=True)
print(E)
ans = 0
for i in range(K):
    ans += E[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split(" ")))
p = list(map(int, input().split(" ")))
p.sort(reverse=True)
res = 0
for i in range(K):
  m = 0
  for k in range(1, p[i]+1):
    m += k
  res += m / p[i]

print(float(res))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort(reverse = True)
ans = []
x = 0
for i in range(k):
    x += 0.5*(p[i] +1)
print(x)

Submission status: Wrong Answer

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

k = [0]*N

def kitaiti(n):
    sum = 0
    for i in range(1,n+1):
        sum += i
    return sum / n
    
for i in range(N):
    k[i] = kitaiti(p[i])

ans = 0
for i in range(N-3):
    ans = max(ans,k[i]+k[i+1]+k[i+2]+k[i+3])
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    res = 0
    maxI = 0
    maxV = sum(P[:K])
    for i in range(1, N-K+1):
        v = maxV + P[i+K-1] - P[i-1]
        if v > maxV:
            maxV = v
            maxI = i
    res = (sum(P[maxI:maxI+K]) + K) / 2.0
    print(res)

main()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
X=0
for k in range(K):
	X+=P[k]

for n in range(1,N-K+1):
	#if P[n-1]<P[n+K-1]:
	#	X=X+P[n+K-1]-P[n-1]
	#	maxn=n
	X=max(X,X+P[n+K-1]-P[n-1])
	print(n,n+K-1,(X+P[n+K-1]-P[n-1])/2)

print((X+K)/2)

Submission status: Wrong Answer

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

if (K == 1):
    print(max(P))
    exit()


for i in range(len(P) - (K - 1)):
    tmp = sum(P[i: i + K])

    if (tmp > total):
        index = i
        total = tmp

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

print(answer)

Submission status: Wrong Answer

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

wa = sum(P[:K])
ind = 0
for i in range(1, N - K+1, 1):
    tmp = wa + P[i+K-1] - P[i-1]
    if tmp > wa:
        wa = tmp
        ind = i
    else:
        pass
# 期待値を求める
ans = 0

for i in range(ind, ind+K, 1):
    now = P[i]
    ans += (now+1) / 2
print("{:.10f}".format(ans))

Submission status: Wrong Answer

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


Psoat = sorted(P, reverse=True)

ans = 0
for i in range(K):
    ans = ans+Psoat[i]*0.5+0.5
    

print(ans)

Submission status: Wrong Answer

Solution code:
# きりみんちゃんの配信をみてたので期待値は分かる
# 素直にTLEくらったので累積和で加減する
n, k = map(int, input().split())
arr = list(map(int, input().split()))
lis = [0 for _ in range(n)]
lis2 = [0 for _ in range(n + 1)]
for i in range(n):
    lis[i] = sum(list(range(1, arr[i] + 1))) / arr[i]

lis2[0] = lis[0]
ans = 0
for i in range(n - 1):
    if i + 1 < k:
        lis2[i + 1] = lis2[i] + lis[i + 1]
    else:
        lis2[i + 1] = lis2[i] + lis[i + 1] - lis[i - k + 1]
    ans = max(ans, lis2[i + 1])
print(ans)

Submission status: Wrong Answer

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

ave_pl = []
for i, p in enumerate(pl):
    p_sum = p*(p+1)/2
    if i == 0:
        ave_pl.append(p_sum/p)
    else:
        ave_pl.append(ave_pl[i-1]+(p_sum/p))

ans = 0
for i in range(k-1, n):
    if i == 0:
        ans = max(ans, ave_pl[i])
    else:
        ans = max(ans, ave_pl[i]-ave_pl[i-k])

print(ans)

Submission status: Wrong Answer

Solution code:
def su(n):
    ans=0
    for i in range(1,n+1):
        ans+=i
    return ans
n,k=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p,reverse=True)
ans=0
for i in range(k):
    ans+=su(p[i])/p[i]
print(ans)

Submission status: Wrong Answer

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

for i in range(N):
    E.append((sum(range(1,p[i]+1)))/p[i])

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

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
box = list(map(int, input().split()))
box.sort(reverse=True)
ans = 0
for i in range(b):
  for j in range(box[i]):
    ans += (j+1)/box[i]
print(ans)

Submission status: Wrong Answer

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

p.reverse()

c=0

for i in range(0,k):
  z=0
  for j in range(0,p[i]+1):
    z+=j
#  print(z)
#  print(p[i])
  c+=z/p[i]
print(c)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

ave_pl = []
for i, p in enumerate(pl):
    p_sum = p*(p+1)/2
    if i == 0:
        ave_pl.append(p_sum/p)
    else:
        ave_pl.append(ave_pl[i-1]+(p_sum/p))

print(ave_pl)
ans = 0
for i in range(k-1, n):
    if i == 0:
        ans = max(ans, ave_pl[i])
    else:
        ans = max(ans, ave_pl[i]-ave_pl[i-k])

print(ans)

Submission status: Wrong Answer

Solution code:

N, K = map(int,input().split(" "))
P = map(int,input().split(" "))
'''
print(sorted(P, reverse=True)[:K])

ans = 0
for p in sorted(P, reverse=True)[:K]:#でかいのkつ取り出す
    print(p)
    e = 0
    for i in range(1,p+1):
        e += i/p
    ans += e

print(ans)
'''



E = []
for p in P:
    e = 0
    for i in range(1,p+1):
        e += i/p
    E.append(e)

#print(E)
print(sum(sorted(E, reverse=True)[:K]))#でかいのkつ取り出してsum

Submission status: Wrong Answer

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

i=0
P_=[]
N_=N+1
res=0
for j in range(K,N_):
    if res<sum(P[i:j]):
        res=sum(P[i:j])
        P_=P[i:j]
    i+=1
print(P_)
ans=0
for i in range(K):
    ans+=(P_[i]*(P_[i]+1)//2/P_[i])

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def culc_expected_value(num):
  output = 0
  if num != 1:
    for i in range(1, num+1):
      output += i/num
  else:
    output = 1
  return output

n, k = map(int, input().split())
desc_p_list = sorted(map(int, input().split()), reverse=True)
targets = desc_p_list[:k]
# print(targets)

ans = 0
for t in targets:
  ans += culc_expected_value(t)
  # print(ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p=list(map(lambda x:(x+1)/2, p))
p_cs=np.cumsum(p)
max_exp=0
for i in range(N-K):
  exp=p_cs[i+K]-p_cs[i]
  if exp>max_exp:
    max_exp=exp
print(max_exp)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K=map(int, input().split())
P=np.array(list(map(int, input().split())))

best=0
bestP=[0]*K
for i in range(N-K):
  if P[i:i+K].sum()>best:
    best=P[i:i+K].sum()
    bestP=P[i:i+K]
    

ans=0
for p in bestP:
  ans+=(p+1)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

NK = input().split()
N = int(NK[0])
K = int(NK[1])
P = input().split()
P = np.array([int(p) for p in P])
per = 1/P
wa = P*(P+1)/2


s = wa*per
max = 0
for i in range(N-K):
  l = s[i:K+i].sum()
  if l > max:
    max = l
print(max)

Submission status: Wrong Answer

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

#処理
#内部関数
def d_1(x):
    t=0
    for i in range(1,x+1):
        t+=i/x
        
    return t

P=[ d_1(i) for i in P]#出る目を期待値に変換

x=sum(P[:K])

for i in range(N-K):
    if P[i]-P[i+K]<0:
        x=x-P[i]+P[i+K]
        
print(x)

Submission status: Wrong Answer

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

    pN_ = []

    ans = 0
    total = 0
    for i, s in enumerate(input().split()):
        total += 1 + int(s)
        pN_.append(total)

        if i == K - 1:
            ans = max(ans, (total - pN_[i]) / 2)
        elif K <= i:
            ans = max(ans, (total - pN_[i - K]) / 2)

    print(ans)


main()

Submission status: Wrong Answer

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

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

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

print("{0:.8f}".format((ans+K)*0.5))

Submission status: Wrong Answer

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

m = 0
t = 0

for i in range(N - K, 0, -1):
    if m < sum(li[i:i+4]):
        m = max(m, sum(li[i:i+4]))
        t = i

ans = 0

for i in range(t, t + K):
    if li[i] == 1:
        ans = ans + 1
    else:
        ans = ans + li[i] + 1

ans = ans / 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    res = 0
    maxI = 0
    maxV = sum(P[:K])
    for i in range(1, N-K+1):
        # v = sum(P[i:i+K])
        v = maxV - P[i-1] + P[i]
        if v > maxV:
            maxV = v
            maxI = i
    res = (sum(P[maxI:maxI+K]) + K) / 2.0
    print(res)

main()

Submission status: Wrong Answer

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

# ans = 0
# for i in range(n-k+1):
#     e = 0
#     for j in range(k):
#         e += ((1+p[i+j])*p[i+j]/2)/p[i+j]
#     ans = max(ans, e)
# print(ans)

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

mx = (0, 0)
for i in range(n-2):
    idx = i+2
    mx = max(mx, (cum[i+3]-cum[i], idx))

ans = 0
for i in range(k):
    ans += ((1+p[mx[1]-i])*p[mx[1]-i]/2)/p[mx[1]-i]
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
e=[(x+1)/2 for x in list(map(int,input().split()))]
m=max(e)
arr=[]

for i in range(n-k+1):
  tmp=e[i:i+k]
  if m in tmp:
    arr.append(sum(tmp))

print(max(arr))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(float,input().split()))
x=[0.0]*n
for i in range(n):
	x[i]=(p[i]*(p[i]+1)/2)/p[i]
v=[0]*(n-k+1)
print(x)
for i in range(n-k+1):
	for j in range(k):
		v[i]+=x[i+j]
print(max(v))

Submission status: Wrong Answer

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

P_ave = []

for p in P:
    P_ave.append((p + 1) / 2)

P_ave_sum = []

for i in range(n):
    P_ave_sum.append(sum(P_ave[:i + 1]))

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

print(max)

Submission status: Wrong Answer

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc(A):
    res = 0
    res = (1+A)/2
    return res
    
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort(reverse=True)
Q = P[:K]
res = 0
for q in Q:
    res += calc(q)
print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,K = inputMap()
	P = inputList()

	kikan1 = 0
	maaxx = 0
	base = 0
	for i in range(N):
		if i == 0:
			tmp = 0
			for j in range(K):
				tmp += P[i+j]
			base = tmp
			continue

		if i+K >= N:
			break
		tmp = base - P[i-1] + P[i+K]
		if tmp > maaxx:
			maaxx = tmp
			kikan1 = i+1

	ans = 0
	for j in range(K):
		tmp = P[kikan1+j]
		total = 0
		for jj in range(1,tmp+1):
			total += jj
		ans += total/tmp

	print(ans)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
P = list(map(int,input().split()))
res = 0
index = 0
def get_mean(q):
    enom = q * (1 + q) / 2
    num = q
    return enom / num
for i in range(N - K + 1):
    val= sum(P[i:i+K])
    res = max(res,val)
    if val == res:
        index = 1
print(sum([get_mean(q) for q in P[i:i+K]]))

Submission status: Wrong Answer

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K=input_int()
P= many_int()

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

maxs = 0
temp = sum(kitaiti[:K])
for i in range(N-K):
    if temp > maxs:
        maxs = temp
    temp += kitaiti[i+K]
    temp -= kitaiti[i]


print(maxs)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
#a=[(1+i)/2 for i in a]
import itertools
ac=itertools.accumulate(a)
ac=list(ac)

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

print((ans+k)/2)

Submission status: Wrong Answer

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

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

pn_max = 0
for i in range(0, n-2):
  pn = ps[i]+ps[i+1]+ps[i+2]
  pn_max = max(pn_max, pn)

print((pn_max+3)/2)

Submission status: Wrong Answer

Solution code:
import numpy as np
K,N = list(map(int,input().split()))
arr = np.array(list(map(int,input().split())))
arr = arr.cumsum()
_sum = 0
for i in range(len(arr)-N+1):
  if i==0:
    tmp = arr[N-1]
  else:
    tmp = arr[N+i-1]-arr[i-1]
  _sum = max(_sum,tmp)

print((_sum+N)//2)

Submission status: Wrong Answer

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

s = sum(P[0:K])
id = 0
for i in range(1, N - K + 1):
    total = s - P[i - 1] + P[i + K - 1]
    if total > s:
        id = i
        s = total

ans = 0
for j in range(id, id + K):
    ans += sum([n for n in range(1, P[j] + 1)]) / P[j]
print(ans)

Submission status: Wrong Answer

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

exarr = [(i+1)/2 for i in arr]
tmpsum = sum(exarr[:k])
sol = 0

for i in range(n-k):
    tmpsum = tmpsum - exarr[i] + exarr[i+k]
    sol = max(sol,tmpsum)
    
print(sol)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dp=[0]*n
ans=0
for i in range(n):
  dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i]
  if i>k:
    ans=max(ans,sum(dp[i-k:i]))
print(ans)

Submission status: Wrong Answer

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

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

s.sort(reverse=True)

Ex = []

for k in range(K):
  me = 0
  for i in range(s[k]+1):
    me += i
  Ex.append(me/s[k])

print(sum(Ex))

Submission status: Wrong Answer

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

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

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

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def main():
    n,k = map(int, input().split())
    l = list(map(int, input().split()))
    out = 0

    for i in range(len(l)-(k-1)):
        result = 0
        for j in range(k):
            print("value {}".format(l[i+j]))
            result += sum(range(l[i+j]+1))/l[i+j]
            print("result {}".format(result))

        if out < result:
            out = result
            print("out {}".format(out))

    print(out)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

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

P2 = [Decimal(n*(n+1))/(2*n) for n in P]

S = sum(P2[:K])
max_s = S
for i in range(1, N-K):
    S -= P2[i-1]
    S += P2[i+K]

    max_s = max(max_s, S)

# print(f'{max_s:.9f}')
print('{:.10f}'.format(max_s))

Submission status: Wrong Answer

Solution code:
import numpy

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

List=list(map(int,input().split()))
EList = []

for i in range(len(List)):
  a = List[i]
  b = (a+1)/2
  EList.append(b)
  

res = numpy.cumsum(EList)
ans = 0
for i in range(len(List)):
  if i < K-1:
    ans = 0
  else:
    ans = float(max(res[i] - res[i-K],ans))
  
print(float(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0] * N
E[0] = sum(P[:K])

for i in range(1, N-K):
  E[i] = E[i-1] + P[i+K-1] - P[i-1]

E[N-K] = sum(P[N-K:])
maxE = max(E)
print(E)
print((maxE - K) / 2.0 + K)

Submission status: Wrong Answer

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

N, K = list(map(int, input().split()))
p_list = list(map(int, input().split()))
c_list = []

k_list = []
total = 0
for x in range(1001):
    total += x
    if x == 0:
        k_list.append(0)
    else:
        k_list.append(total / x)

max_t = -float("inf")
max_kp = -float("inf")
kp_list = []
for i, p in enumerate(p_list):  # 200000
    kp = k_list[p]
    if i != 0:
        c_list.append(c_list[i - 1] + p)
        kp_list.append(kp_list[i - 1] + kp)
    else:
        c_list.append(p)
        kp_list.append(kp)

    if i >= K - 1:
        t = c_list[i] - c_list[i - K]

        if t > max_t:
            max_kp = kp_list[i] - kp_list[i - K]
            max_t = t

ans = max_kp
print(ans)

Submission status: Wrong Answer

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


P = list(map(int, input().split()))
P = [(1 + k)*(k/2)/k for k in P]
P.sort(reverse=True)
s = 0
for i in range(K):
    s += P[i]
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    pp = list(map(int, input().split()))
    i = 0
    maxi = 0
    while i < n - k:
        if pp[i] < pp[i + k]:  # 増加しているなら
            maxi = i + 1
        i += 1
    print((sum(pp[maxi:maxi + k]) + k) / 2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# D
N, K = map(int, input().split())
lst = list(map(int, input().split()))
ma = 0
idx = 0
for i in range(len(lst)-(K-1)):
    if (ma < sum(lst[i:i+K])):
        ma = sum(lst[i:i+K])
        idx = i
ans = 0
print()
for i in lst[idx:idx+K]:
    ans += (i+1) / 2 
print(ans)

Submission status: Wrong Answer

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


pp = sorted(p)
#p.sorted()

ans = 0

for i in pp[n-k:]:
        ans += (1+i)/2
else:
        print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
sums=[sum(j for j in range(i+1)) for i in range(1001)]
ans=0

for i in range(K):
    ans+=sums[P[i]]/P[i]
tmp=ans

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np 
N, K = input().split(" ")
ps = input().split(" ")
N, K = int(N), int(K)
ps = np.array([int(p) for p in ps])
p_max = ps.max()
e_list = np.zeros(p_max+1, dtype=np.float64)
for i in range(1, p_max+1):
    e_list[i] = np.mean(np.arange(i) + 1) 
max_e = 0
idx = 0
for i in range(N-K+1):
    sum_p = ps[i:i+K].sum()
    if p_max < sum_p:
        idx = i  
        p_max = sum_p
_ps = ps[idx:idx+K]
e = e_list[_ps].sum()
if e > max_e:
    max_e = e  
print(e)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d = sorted(list(map(int, input().split())))[(k-1):]
sum1 = 0
s = 0
old = 0
oldsum = 0
for i in d:
    dice = list(range(1+old,i+1))
    if len(dice) != 0:
        s = sum(dice) + oldsum
        ex = s / (len(dice) + old)
        sum1 += ex
        old = i
        oldsum = s

print(sum1)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
m=sum(A[:k])
M=0
for i in range(n-k):
    m=m-A[i]+A[i+k]
    M=max(M,m)
print((M+k)/2)

Submission status: Wrong Answer

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


s_max = sum(P[:K])
print(s_max)
s = s_max
for i in range(K, N):
    print(P[i], P[i - K])
    s = s + P[i] - P[i - K]
    s_max = max(s_max, s)

print((s_max + K)  / 2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def calc_expect(n):
    return (n+1) / 2


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

p_expect_list = list(map(calc_expect, p_list))

max_val = 0

res = [0] * len(p_expect_list)
res[0] = p_expect_list[0]
for i in range(len(res)-1):
    res[i+1] = res[i] + p_expect_list[i+1]

for i in range(len(p_expect_list)-k):
    val = res[i+k]-res[i]
    if val > max_val:
        max_val = val

print(max_val)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
sums=[sum(j for j in range(i+1)) for i in range(1001)]
ans=0

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
max_l = 0
point = sum(p[:K])
index = -1

for i in range(1,N-K+1):
  point -= (p[i-1] - p[i+K-1])
  if point > max_l:
    max_l = point
    index = i
print(sum([(n+1)/2 for n in p[index:index+K]]))

Submission status: Wrong Answer

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

l = list(map(int, input().split()))
dp = [0.5+0.5*i for i in range(max(l)+1)]
dp[0] = 0

# print(dp)
tmp = 0
for i in range(k-1):
    tmp += dp[l[i]]

ans = 0
for i in range(n-2):
    tmp += dp[l[i+2]]
    ans = max(ans, tmp)
    tmp -= dp[l[i]]
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
max=0
sump=0
mxpst=0
ans=0
for i in range(k):
    max+=p[i]
sump=max
for i in range(n-k):
    sump=p[i+k]+max-p[i]
    if sump>max:
        max=sump
        mxpst=i+1
for i in range(k):
    ans+=(p[mxpst+i]+1)/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())))

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

m = 0
for i in range(N-K+1):
  new = np.sum(pp[i:i+K]/p[i:i+K] )
  if m<new:
    m=new
print(new)

Submission status: Wrong Answer

Solution code:
def acinput():
    return list(map(int, input().split(" ")))


import numpy as np

N,K=acinput()
p=np.array(acinput())

pp=(p+1)/2
p_cs=np.cumsum(pp)

res=0

for i in range(K-1,N):
    res=max(res,(p_cs[i]-p_cs[i-K]))
    #tmp = (p[i:(i+K)]+1)/2
    #res = max(res, np.sum(tmp))


print(res)

Submission status: Wrong Answer

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

P2 = [(n*(n+1))/2/n for n in P]

S = sum(P2[:K])
max_s = S
for i in range(1, N-K):
    S -= P2[i-1]
    S += P2[i+K]

    max_s = max(max_s, S)

# print(f'{max_s:.9f}')
print('{:.9f}'.format(max_s))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
dice=map(float,input().split())
#dic=[]
#for i in dice:
#    dic.append(int(i))

kitai=[]
for d in dice:
    wa=float((1/2)*d*(d+1))
    kitai.append(float(wa/d))

s=[]
for j in range(K):
    su=sum(kitai[j:j+K])
    s.append(su)
print(max(s))

Submission status: Wrong Answer

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

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

ans=(sum(p[maxim:maxim+k])+k)/2
print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
top_k_idx = np.argsort(p)[-K:]
top_k_values = [p[i] for i in top_k_idx]
expected_values = map(lambda x: (x + 1) / 2.0, top_k_values)
print(sum(expected_values))