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: Time Limit Exceeded

Solution code:
from collections import deque
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
sums = deque([0]*K)
ans = 0
for pi in map(int, input().split()):
  sums.popleft(); sums.append(E(pi))
  ans = max(ans, sum(sums))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
sums = deque([0]*K)
ans = 0
for pi in map(int, input().split()):
  sums.popleft(); sums.append(E(pi))
  ans = max(ans, sum(sums))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n,k=map(int,input().split())
p=[ int(i) for i in input().split() ]
kitaichi_list=[]
cnt=kitaichi=wa=0

for i in p:
    kitaichi_list.append( (1+i)/2 )
    cnt+=1
    if cnt>=k:
        kitaichi=sum(kitaichi_list[cnt-k:cnt])
        if kitaichi>=wa:
            wa=kitaichi

print(wa)

Submission status: Time Limit Exceeded

Solution code:
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
Es = [E(pi) for pi in map(int, input().split())]
sums = [sum(Es[:i]) for i in range(N+1)]
print(max([sj-si for sj,si in zip(sums[K:],sums)]))

Submission status: Time Limit Exceeded

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-1)):
  v=p[i:K+i]
  smax=sum(v)
  #e=(K+smax)/2

  max_e = max(max_e, smax)
    
print(max_e)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

ans = 0
perm = deque([(P[i]+1)/2.0 for i in range(K-1)])

for i in range(K-1, N):
    perm.append((P[i]+1)/2.0)
    if ans < sum(perm):
        ans = sum(perm)
    perm.popleft()

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=0
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
    kouho=kitaiti
for j in range(N-K+1):
    if j==0:
        continue
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako.pop(0)
        kouho=max(kouho,kitaiti)
#print(kouho)
print(kouho)

Submission status: Time Limit Exceeded

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

max_e = 0

for i in range(N - K + 1):
    e = 0
    for j in range(K):
        e += p[i + j]
    if e > max_e:
        max_e = e

print((max_e + K) / 2)

Submission status: Time Limit Exceeded

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

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

p, sp = [], []
for i in range(N):
    p.append((P[i] + 1) / 2)

for i in range(N - K + 1):
    sp.append(sum(p[:i + K]) - sum(p[:i]))

print('{:.10f}'.format(max(sp)))

Submission status: Time Limit Exceeded

Solution code:
x=0
y=0
N,K=map(int,input().split())
P=list(map(int,input().split()))
i=1
while i+K<N+1:
  if sum(P[i:i+K])>x:
    x=sum(P[i:i+K])
    y=i
  i=i+1
 
S=0
for i in range(y,y+K):
  S=S+(1+P[i])/2
print(S)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b= map(int, input().split())
*l, = map(int, input().split())
A = []
for i in range(a):
  A.append(sum(l[i:i+b])) 
B = (max(A))/2 + b/2
print("{:.6f}".format(B))

Submission status: Time Limit Exceeded

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

exv = [(1 + array[i]) / 2 for i in range(K)]
max_num = sum(exv)

for i in range(K, N):
    del exv[0]
    exv.append((1 + array[i]) / 2 )
    sum_exv = sum(exv)
    if sum_exv > max_num:
        max_num = sum_exv
print(max_num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np

def get_expectation(n):
    # return sum([i/n for i in range(1,n+1)])
    return (1+n)/2

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

box = [P]
for i in range(1,K):
    box.append(P[i:]+[0]*i)

# large = np.sum(np.array(box),axis=0)
# ind = np.argmax(large)

best = P[:K]
sum_best = sum(best)
last_sum = sum(P[:K])

for i in range(1,len(P)-K+1):
    box = P[i:i+K]
    sum_box = last_sum - P[i-1] + P[i+K-1]
    if sum_box > sum_best:
        best = box
        sum_best = sum_box
    last_sum = sum_box

a = 0
for i in best:
    a += get_expectation(i)
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
num = 0
maxnum = 0
for i in range(n-k+1):
    num = sum(p[i:i+k])
    if num > maxnum:
        maxnum = num
print("{:.6f}".format(0.5*(maxnum+k)))

Submission status: Time Limit Exceeded

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

#max_k = max(k)

sum_k = 0
max_i = 0
max_sum = 0
for i in range(n-k+1):
  sum_k = 0
  for j in range(i,i+k):
    sum_k += p[j]
  if max_sum < sum_k:
    max_sum = sum_k
    max_i = i

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

print(ans)

Submission status: Time Limit Exceeded

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):
		if T<=S[n+K]-S[n]:
			T=S[n+K]-S[n]

	print((T+K)/2)

Submission status: Time Limit Exceeded

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

Sim = [sum(Pi[0:i]) for i in range(N+1)]
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
p = 0
ma = 0
for i in range(0,N-K+1):
  q = 0
  for j in range(K):
    q += P[j+i]
  if ma < q:
    p = i
    ma = q
s = 0
for i in range(p, p+K):
  for j in range(1, 1+P[i]):
    s += (j)*(1/P[i])
print(s)

Submission status: Time Limit Exceeded

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

# 期待値のリスト生成
ex_list = list()
for i in range(len(p)):
	ex_list.append((1+p[i])/2)

ans = 0
for i in range(N-K+1):
	ex = sum(ex_list[i:i+K])
	if ans < ex:
		ans = ex

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n):
    p[i]=(p[i]+1)/2#p[i]を期待値に変更
    
max_sum=0    
for i in range(n-k+2):
    max_sum=max(max_sum,sum(p[i:i+k]))
print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[]
for i in range(len(B)-A[1]+1):
  D=0
  for j in range(A[1]):
    D=D+B[i+j]
  C.append(D)
print((max(C)+A[1])/2)

Submission status: Time Limit Exceeded

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):
		T.append(S[n+K]-S[n])
	print((max(T)+K)/2)

Submission status: Time Limit Exceeded

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

ans = 0
perm = [(P[i]+1)/2.0 for i in range(K-1)]

for i in range(K-1, N):
    perm.append((P[i]+1)/2.0)
    if ans < sum(perm):
        ans = sum(perm)
    perm.pop(0)

print(ans)

Submission status: Time Limit Exceeded

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

    ans = [0] * N
    max_tmp = [0] * K
    start_index = 0
    for i in range(N - K + 1):
        tmp = P[i: i + K]
        ans[i] = (1 + P[i]) / 2
        if sum(max_tmp) < sum(tmp):
            max_tmp = tmp
            start_index = i

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

    print(sum(ans[start_index: start_index + K]))


resolve()

Submission status: Time Limit Exceeded

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

for i in range(n - k + 1):
    sum = 0
    for j in range(k):
        sum += p_list[i + j]
    if sum > max:
        max = sum
        index = i

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

print(value)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n, k = [int(i) for i in input().split()]
li = [int(i) for i in input().split()]
ruiseki = []
kitaiti = []
goukei = []

for i in li:
    a = itertools.accumulate(list(range(1,i+1)))
    a = list(a)
    ruiseki += [a[-1]]

for i in range(n):
    kitaiti.append(ruiseki[i] / li[i])

for i in range(n - k + 1):
    goukei.append(sum(kitaiti[i:i+k]))

print(max(goukei))

Submission status: Time Limit Exceeded

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

sum_k = 0
max_i = 0
max_sum = 0
for i in range(n-k+1):
  sum_k = 0
  for j in range(i,i+k):
    sum_k += p[j]
  if max_sum < sum_k:
    max_sum = sum_k
    max_i = i

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

print(ans)

Submission status: Time Limit Exceeded

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

    ans = []
    l = []
    for i in range(N-K+1):
        l.append(sum(P[i:i+K]))
    idx = l.index(max(l)) 
    ls = P[idx:K+idx]
    for j in range(K):
        ans.append((ls[j]+1)*ls[j]/(2*ls[j]))
    print(sum(ans))
main()

Submission status: Time Limit Exceeded

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 + 1) / 2
    print(res)
resolve_D()

Submission status: Time Limit Exceeded

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

def main():
    _, K = map(int, input().split())
    P = list(map(int, input().split()))

    max_average = 0
    point = 0
    for i in range(len(P)-K+1):

        if max_average < sum(P[i:i+K]):
            max_average = sum(P[i:i+K])
            point = i

    count = 0
    for p in range(point, point+K):
        count += sum(range(1, P[p]+1)) / P[p]

    print(count)

main()

Submission status: Time Limit Exceeded

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

Max = k
min = 0
T = []
Epi = 0

while(Max <= n):
  for i in range(min, Max):
    Epi = Epi + (p[i]+1)/2
  T.append(Epi)
  Epi = 0
  Max += 1
  min += 1
print(max(T))

Submission status: Time Limit Exceeded

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def ex(s):
    n = int(s)
    return sum(list(range(1, n+1))) / n

# main
N, K = mis()
exs = list(map(ex, input().split()))

if N == K:
    print(sum(exs))
    exit(0)

ex_max = 0

for i in range(K):
    ex_max += exs[i]

left = 0
ex_temp = ex_max
for i in range(K, N):
    ex_temp = ex_temp - exs[left] + exs[i]
    left += 1
    if ex_max < ex_temp:
        ex_max = ex_temp

print('{:.7f}'.format(ex_max))

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
num = 0
maxnum = 0
for i in range(n-k+1):
    num = 0.5*(sum(p[i:i+k])+k)
    if num > maxnum:
        maxnum = num
print("{:.6f}".format(maxnum))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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]

max1 = 0
tmp = 0
for j in range(n):
    if len(e[j:j+k]) < k:
        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        max1 = tmp
print(max1)

Submission status: Time Limit Exceeded

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

#print('N, K = ', N, K)
#print('p = ', p)

s = []
#print('K', K)

for i in range(N-(K-1)):
  s.append(sum(p[i:i+(K)]))
#  print(p[i:i+(K)])

#print('s = ', s)

n = s.index(max(s))
#print('n', n)

lis = p[n:n+K]
#print('lis', lis)

num = [int(i+1) for i in range(max(lis))]
#print('num' , num)

ki = 0

for i in range(K):
  ki = ki + sum(num[0:0+lis[i]]) / lis[i]
#  print(num[0:0+lis[i]])
#  print('ki', ki)

print(ki)

Submission status: Time Limit Exceeded

Solution code:
def main():
  def CalExVal(x):
    return (1/2*(x+1))
  N, K = map(int, input().split())
  A = list(map(int, input().split()))


  Ex = list((map(CalExVal, A)))
  temp = len(A)-K + 1
  adjlist = [0]*(temp)
  #adjlist = [sum(list(map(CalExVal, A))[i:(K+i)]) for i in range(temp)]
  res = 0
  for i in range(temp):
      adjlist[i] = sum(Ex[i:(K+i)])
      if res < adjlist[i]:
      	res = adjlist[i]
  print(res)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def expected_value(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(sum(expected_value(arr[max_i:max_i + k])))

Submission status: Time Limit Exceeded

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

def InMap(): return tuple(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: Time Limit Exceeded

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

    max_average = 0
    point = 0
    for i in range(len(P)-K+1):

        if max_average < sum(P[i:i+K]):
            max_average = sum(P[i:i+K])
            point = i

    count = 0
    for p in range(point, point+K):
        count += sum(range(1, P[p]+1)) / P[p]

    print(count)

main()

Submission status: Time Limit Exceeded

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

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

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
        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

print((max_sum+k)/2)

Submission status: Time Limit Exceeded

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

 
print((aaa+k)/2)

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

Solution code:
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    hash_max = 0
    for i in range(0, N - K + 1):
        if sum(p_list[i:i + K]) > hash_max:
            hash_max = sum(p_list[i:i + K])
    print(hash_max)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ma = 0
for i in range(a[0]-a[1]+1):
    c=b[i:i+a[1]]  #K個取りだす 
    ma=max(ma,sum(c))

print((ma+a[1])/2)

Submission status: Time Limit Exceeded

Solution code:
def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
sumlist = [sum(P[i:i+K]) for i in range(N-K+1)]
print(max(sumlist))

Submission status: Time Limit Exceeded

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

def kitai(x):
  return (1+int(x))/2

p = list(map(kitai, input().split()))

isum = 0
for i in range(n):
  if i+k > n:
    break
  temp = p[i:i+k]
  if sum(temp) > isum:
    isum = sum(temp)

print(isum)

Submission status: Time Limit Exceeded

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]

max1 = 0
idx = 0
tmp = 0
for j in range(n):
    if len(e[j:j+k]) < k:
        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        idx = j
        max1 = tmp
print(max1)

Submission status: Time Limit Exceeded

Solution code:

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

tmp = 0
num = []
ans = []
for i in range(N):
    tmp += (P[i] * (P[i] + 1) / 2 / P[i])
    ans.append(tmp)
    tmp -= tmp
    if i >= (K-1):
        num.append(sum(ans[i - K + 1:i + 1]))
print(max(num))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def expect(n):
    return sum(range(1, n+1)) / n

N, K = list(map(int, input().split(" ")))
p = list(map(int, input().split(" ")))
max_list = [0]
for i in range(0, N - K + 1):
    tmp1 = p[i:i+K]
    if sum(tmp1) > sum(max_list):
        max_list = tmp1
tmp2 = 0
for i in max_list:
    tmp2 += expect(i)
print(tmp2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    p[i]=(p[i]+1)/2#p[i]を期待値に変更
    
max_sum=0    
for i in range(n-k+2):
    cnt=sum(p[0:0+k])
    max_sum=max(max_sum,sum(p[i:i+k]))
print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
pp = [(pp+1)/2 for pp in p]
ppp = len(p) - k + 1

su = 0
for i in range(0, ppp):
  su = max(su,sum(pp[i:i+k]))
  
print(su)

Submission status: Time Limit Exceeded

Solution code:
#import heapq

def dice(p):
    return (1+p)/2
    #sum = 0
    #for i in range(1,p+1):
    #    sum += i/p
    #return sum

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

m = 0
l = []
for i in range(n-k+1):
    t = sum(p[i:i+k])
    if(m <= t):
        l = p[i:i+k]
        m = t
#print(l)
#l = heapq.nlargest(k, p)
#print(l)


dist = {}
res = 0
for i in l:
    if i in dist:
        ans = dist[i]
    else:
        dist[i] = dice(i)
    res += dice(i)

print(res)

Submission status: Time Limit Exceeded

Solution code:
def dice_eq(x):
    eq=(x+1) / 2
    return eq
equit=0
N,K=map(int,input().split())
data=list(map(int,input().split()))
#print(data)
ansb=[]
for j in range(N):
    equit=dice_eq(data[j])
    ansb.append(equit)
kt=0
#print(ansb)
ansc=[sum(ansb[m:m+K]) for m in range(0,N-K+1)]

#print(ansc)
max=max(ansc)
print(max)

Submission status: Time Limit Exceeded

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def ex(n):
    return sum(list(range(1, n+1))) / n

# main
N, K = mis()
p = lmis()

exs = [0] * N

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

if N == K:
    print(sum(exs))
    exit(0)

ex_max = 0

for i in range(K):
    ex_max += exs[i]

left = 0
ex_temp = ex_max
for i in range(K, N):
    ex_temp = ex_temp - exs[left] + exs[i]
    left += 1
    if ex_max < ex_temp:
        ex_max = ex_temp

print('{:.7f}'.format(ex_max))

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N, K = int(NK[0]), int(NK[1])
lis_p = list(map(lambda x: int(x), input().split()))
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Submission status: Time Limit Exceeded

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

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

X=N-K+1

for i in range(X):
    newS = 0
    for j in range(K):
        newS += p[i+j]

    if newS > S:
        S = newS

E=(S+K)/2

print(E)

Submission status: Time Limit Exceeded

Solution code:
def cal(a):

    return ((1 + a) / 2)

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

for i in range(0, N):
    p[i] = cal(p[i])

for i in range(0, N - K + 1):
    ans = 0
    for j in range(i, i + K):
        ans += p[j]
    ans_raw.append(ans)


print(max(ans_raw))

Submission status: Time Limit Exceeded

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

max = -1
ans=0


for i in range(0,n-k+2):
    buf = p[i:i+k]
    tmp = sum(buf)
    if tmp > max:
        max = tmp
        li = p[i:i+k]

for j in range(len(li)):
    ans += (1+li[j])/2
    
print(ans)

Submission status: Time Limit Exceeded

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

pp = len(p) - k + 1

su = 0
for i in range(0, pp):
  su = max(su,sum(p[i:i+k]))
  
print(su)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def expect(n):
    return sum(range(1, n+1)) / n

N, K = list(map(int, input().split(" ")))
p = list(map(int, input().split(" ")))
max_list = [0]
for i in range(0, N - K + 1):
    if sum(p[i:i+K]) > sum(max_list):
        max_list = p[i:i+K]
tmp = 0
for i in max_list:
    tmp += expect(i)
print(tmp)

Submission status: Time Limit Exceeded

Solution code:
def dice_eq(x):
    eq=0
    for i in range(x):
        eq+=(i+1)/x
    return eq
equit=0
N,K=map(int,input().split())
data=list(map(int,input().split()))
#print(data)
ansb=[]
for j in range(N):
    equit=dice_eq(data[j])
    ansb.append(equit)
kt=0
#print(ansb)
ansc=[sum(ansb[m:m+K]) for m in range(0,N-K+1)]

#print(ansc)
max=max(ansc)
print(max)

Submission status: Time Limit Exceeded

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])
print(sum(ans1))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from operator import add
import copy

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

l = copy.copy(p)
for i in range(K-1):
    p.remove(p[0])
    l = list(map(add, l, p))

print("{:.12f}".format((max(l)+K) /2))

Submission status: Time Limit Exceeded

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

ans2 = list()
for i in range(n - (k-1)):
    ans2.append(P[i:i+k])
ans = 0
ans5 = list()

for i in ans2:
    ans = 0
    for j in i:
        ans += (1+j)/2
    ans5.append(ans)
print(max(ans5))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
ex = list(map(lambda x: (int(x) + 1) / 2, input().split()))
if K == 1:
    print(max(ex))
    exit()
sums = []
for i in range(N - K + 1):
    sums.append(sum(ex[i:i + K]))
print(max(sums))

Submission status: Time Limit Exceeded

Solution code:
# DはN^2だとTLEするなとわかって悩んでたけど
# 部分和に足して引く繰り返してけばいいと気付いた時は天才になった

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


m = sum(p[:k])
for i in range(n-k+1):
  part = sum(p[i:k+i])
  if part > m:
    m = part
  
m += k
print(m/2)

Submission status: Time Limit Exceeded

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

tmp = 0
l = 0
 
while True:
  res = 0
  j = 0
  for j in range(k):
    res = res + e[l + j]
  if tmp < res:
    tmp = res
  l = l + 1
  if l + k > len(e):
    break

print(tmp)

Submission status: Time Limit Exceeded

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


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

t = [0] * n
for i in range(n):
    t[i] = kitaichi(p[i])

ans = 0
for i in range(n-k+1):
    tmp = sum([t[x] for x in range(i, i+k)])
    ans = max(ans,tmp)

print(ans)

Submission status: Time Limit Exceeded

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

pp = len(p) - k + 1
su = 0
for i in range(0, pp):
  if su < sum(p[i:i+k]):
    su = sum(p[i:i+k])

print(su)

Submission status: Time Limit Exceeded

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

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

max1 = 0
idx = 0
tmp = 0
for j in range(n):
    if len(e[j:j+k]) < k:
        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        idx = j
        max1 = tmp
print(max1)

Submission status: Time Limit Exceeded

Solution code:
def ex_value(dice):
  return (1+dice)/2
def main():
  n,k = map(int, input().split())
  list_p = list(map(int, input().split()))
  list_ex_val = list(map(ex_value, list_p))
  print(max([sum(list_ex_val[i:i+k]) for i in range(n-k+1)]))
     
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
res=[]
for i in range(n):
    if i+k>n:break
    tmp=sum(p[i:i+k])
    ans=max(ans, tmp)
    if ans==tmp:
        res=p[i:i+k]
ans=0
for j in res:
    ans+=(1+j)/2
print(ans)

Submission status: Time Limit Exceeded

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

# T[i]に1からiまでの合計値が入っている
# M[i]にiの目があるさいころの期待値が入っている
# T = [0]
# M = [0]
# for j in range(1,1001):
#     T.append(j + T[j-1])
#     K.append(T[j]/j)
# 計算すると(n+1)/2


# M = [0]
# for j in range(1,1001):
#     M.append((j+1)/2)
# # print(K)

# PP = []
# for k in P:
#     PP.append(M[k])
# TEMP = []
ANS = 0
for i in range(N-K+1):
    # TEMP.append(sum(P[i:i+K]))
    TEMP = sum(P[i:i+K])
    if TEMP > ANS:
        ANS = TEMP
# ANS = max(TEMP)
print((ANS+K)/2)

Submission status: Time Limit Exceeded

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

A = []
ans = 0
for i in range(len(P)):
    if ans < sum(P[i:i+K]):
        ans = sum(P[i:i+K])
        A.append(i)
A1 = sorted(A, reverse = True) 
L = A1[0]                
B = P[L:L+K]

C  = []
for i in B:
    C.append(1/2*(i+1))
print(sum(C))