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:
x, y = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(x-y+1):
    z = 0
    for j in range(y):
        z += (p[i+j]+1)/2
    if z > ans:
        ans = z

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

A=[0]*(N-K+1)
for i in range(N-K+1):
    A[i]=sum(E[i:i+K])

print(max(A))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    sum_val = 0
    kitai = []
    for i in range(0, len(daice) - k + 1):
        tmp = daice[i:i + k]
        if sum(tmp) >= sum_val:
            sum_val = sum(tmp)
            kitai = tmp
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
expects_list=[]
for i in range(0,num-renzoku+1):
  expects_list.append(sum(expects[i:i+renzoku]))
print(max(expects_list))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    from collections import deque
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    queue=deque()
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            queue.append(buf)
            ans+=buf
    for i in range(k,n):
        queue.popleft()
        queue.append(kitai[i])
        if ans<=sum(queue):
            ans=sum(queue)
    print(ans)

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
maxwa = 0
for i in range(N-K+1):
    wa = 0
    for j in range(K):
        wa += l[i+j]
    maxwa = max(maxwa,wa)
print((maxwa+K)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split()) 
a = list(map(int,input().split()))
i = 0
max_exp = 0
while i + k <= n:
    exp = 0
    for j in range(k):
        exp += a[i+j]
    if max_exp < exp:
        max_exp = exp
        i += 1
    else:
        i += 1
print((k+max_exp)/2)

Submission status: Time Limit Exceeded

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
ans = 0
for i in range(n-k+1):
    tmp = sum(a[i:i+k])
    if tmp > ans:
        ans = tmp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = list(map(int, input().split()))
P = np.array(list(map(int, input().split())))
E = (P+1)/2.0
EK = 0
for i in range(N-K+1):
    e = np.sum(E[i:i+K])
    if EK < e:
        EK = e
print(EK)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
x = 0
for i in range(n - k + 1):
    s = sum(p[i : i + k])
    if s > max:
        max = s
        x = i
ans = 0
for i in range(x, x + k):
    ans += (p[i] + 1) / 2
print('{:.12f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
Exception_p=[]
for i in range(N):
    Exception_p.append((1+p[i])/2)
sum_Exception=[]
for i in range(N-K+1):
    sum=0
    for k in range(K):
        sum=Exception_p[i+k]+sum        
    sum_Exception.append(sum)
list.sort(sum_Exception)
print(sum_Exception.pop(-1))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,k=map(int,input().split())
p_in=list(map(int,input().split()))
p=np.array([i for i in p_in])
p_list=p[:k]
s=p_list.sum()
index=0
for i in range(n-k+1):
  p_list=p[i:i+k]
  if p_list.sum() > s:
    s = p_list.sum()
    index = i
b=p[index : index + k]
ans=b.sum()/2+k/2
print(ans)

Submission status: Time Limit Exceeded

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

p_list=p[:k]
s=sum(p_list)
index=0
for i in range(n-k+1):
  p_list=p[i:i+k]
  if sum(p_list) > s:
    s = sum(p_list)
    index = i
b=p[index : index + k]
ans=sum(b)/2+k/2
print(ans)

Submission status: Time Limit Exceeded

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

result = []
for i in range(N-K+1):
    total = 0
    for j in range(K):
        total += p[i+j]
    result.append(total)
print(max(result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

mx = 0
for i in range(len(pL) - k + 1):
    sm = 0
    for j in range(k):
        sm += pL[i + j]
    mx = max(sm, mx)

print((mx + k) / 2)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

MV = 0
add = 0
m = 0 #何番目のサイコロを最後に含むか
ev = 0
lst = deque()

for i in range(K, N+1):
    for j in range(i-K, i):
        add += p[j]
        m = j
    if MV < add:
        MV = add
        for k in range(m-K+1, m+1):
            ev += ((p[k]*(p[k]+1))/2)/p[k]
        lst.append(ev)

    add = 0
    ev = 0

print(lst.pop())

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(float, input().split()))
MV = 0
add = 0
m = 0 #何番目のサイコロを最後に含むか
ev = 0
lst = []
for i in range(K, N+1):
    for j in range(i-K, i):
        add += p[j]
        m = j
    if MV < add:
        MV = add
        for k in range(m-K+1, m+1):
            ev += ((p[k]*(p[k]+1))/2)/p[k]

    lst.append(ev)
    add = 0
    ev = 0

print(float(max(lst)))

Submission status: Time Limit Exceeded

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

me = 0
for i in range(N - K + 1):
    e = sum((1 + p) / 2 for p in P[i: i + K])
    me = max(e, me)

print(me)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def calculate(n, k, prr):

    maxSum = 0
    for i in range(n-k+1):
        sum = 0
        for j in range(k):
            sum = sum + (prr[i+j])

        if sum > maxSum:
            maxSum = sum


    print((k+maxSum)/2)


calculate(N, K, PRR)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(n-k+1):
    e = (sum(p[i:i+k]) + k) / 2
    if ans < e:
        ans = e
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for n in range(N-K+1):
	#tmp = sum(list(map(lambda x: (x+1)/2, p[n:n+K])))
	tmp = np.sum((p[n:n+K]+1)/2)
	if ans < tmp:
		ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

for n in range(N-K+1):
	tmp = sum(list(map(lambda x: (x+1)/2, p[n:n+K])))
	if ans < tmp:
		ans = tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def exp(x):
    exp=1/2*(x+1)
    return exp

n,k=map(int,input().split())
p=list(map(int, input().split()))
sum_list=[]
for i in range(n-k+1):
    sum=0
    for j in range(k):
        sum=sum+exp(p[i+j])
    sum_list.append(sum)

print(max(sum_list))

Submission status: Time Limit Exceeded

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

E=[0]*(N)
for i in range(N):
  E[i]=(P[i]+1)/2

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
B,C = list(map(int,input().split()))
n_l = list(map(int,input().split()))
A = []
total = 0
for i in range(B-C+1):
    A.append(sum(n_l[i:i+C]))
place = A.index(max(A))
for i in range(C):
    total += n_l[place+i]+1
print(total*0.5)

Submission status: Time Limit Exceeded

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

d = []

for v in p:
    d.append((1+v)/2)

r=0

for i in range(n-k+1):
    r=max(r,sum(d[i:i+k]))


print(r)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=(1+a[i])/2
x=[0]*(n+k-1)
for i in range(n):
  for j in range(i,i+k):
    x[j]+=a[i]
print('{:.10f}'.format(max(x)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans_list=[]
for i in range(n-k+1):
    a = 0
    for j in range(k):
        a += (1+p[i+j])/2
    ans_list.append(a)
    
ans_list.sort(reverse=True)
print(ans_list[0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a=[0]*n
for i in range(n):
    for j in range(p[i]+1):
        a[i]+=j*(1/p[i])

b=[0]*(n+1)
for i in range(n):
    b[i+1]=b[i]+a[i]

cnt=0
for i in range(len(b)-1):
    cnt=max(cnt,b[i+1]-b[i-k+1])

print(cnt)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

expected_value = []
for i in range(len(p)):
    value = 0
    for j in range(1, p[i] + 1):
        value += j / p[i]
    expected_value.append(value)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))

Submission status: Time Limit Exceeded

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

total = 0

for i in range(len(P)-K+1):
    c = sum(P[i:i+K])
    if c > total:
        total = c


print((total+K)/2)

Submission status: Time Limit Exceeded

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

total = 0
target = 0

for i in range(len(P)-K+1):
    c = sum(P[i:i+K])
    if c > total:
        total = c
        target = i

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(len(P)-K+1):
    c = 0
    for j in range(i, i+K):
        e = (P[j] + 1)/2
        c += e

    if c > ans:
        ans = c

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def sum1(j):
  return (j+1)*j//2

for i in range(n):
  p[i]=sum1(p[i])/p[i]

max1=-1000000000000000
for i in range(n-k+1):
  q=p[i:i+k]
  if sum(q)>max1:
    max1=sum(q)
    
print(max1)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
# print(P)
E = [(p*(p+1))/(2*p) for p in P]
# print([sum(E[i:i+K]) for i in range(N-K+1)])
print(max([sum(E[i:i+K]) for i in range(N-K+1)]))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
def P(x):
    return (x+1)/2
a=0
for i in range(N-K+1):
    y=0#隣接区間の期待値の和
    for j in range(K):
        y+=P(p[i+j])
    if a<y:
        a=y
print(a)

Submission status: Time Limit Exceeded

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

def dice_expctations(num:int)->float:
    return (num+1) / 2

E = list(map(dice_expctations, P))

back = 0
head = k-1
ans = 0
while head <= n-1:
    tmp = 0
    for i in range(back, head+1):
        tmp += E[i]
    if tmp > ans:
        ans = tmp
    else:
        pass
    back += 1
    head += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
N,K=map(int,input().split())
pi=list(map(int,input().split()))
dice=[0]*N
for i in range(N):
    dice[i]=pi[i]*(pi[i]+1)/2/(pi[i])
#print(dice)
a = sum(dice[0:K-1])
max=a
for i in range(N-K+1):
    a=sum(dice[i:i+K])
    #print(dice[i:i+K])
    if a>max:
        max=a

print(max)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
hope = []
for i in range(N):
  hope.append((P[i]+1)/2)

for j in range(N-K+1):
  ans = max(ans,sum(hope[j:j+K]))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
hope = []
for i in range(N):
  hope.append(Decimal((P[i]+1)/2))

for j in range(N-K+1):
  ans = max(ans,sum(hope[j:j+K]))

print(ans)

Submission status: Time Limit Exceeded

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

"""

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

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

Max = -100000
for i in range(n-k+1):
    sum = 0
    for j in range(k):
        sum += p[i+j]
    if Max <= sum:
        Max = sum

print((Max+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

S = []
ans = -1
for i in range(N-K+1):
   S.append((sum(ps[i:i+K]) + K) / 2.)
print(max(S))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

em = 0
exp = []
for i in range(n-k+1):
  temp = sum(p[i:i+k])
  if em <= temp:
    em = temp
    exp = p[i:i+k]

    
print(sum([(pi + 1) / 2 for pi in exp]))

Submission status: Time Limit Exceeded

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

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

em = 0
for i in range(n-k+1):
  em = max(em, sum(expect[i:i+k]))

print(em)

Submission status: Time Limit Exceeded

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

E = []
for i in range(len(P)):
  E.append((1+P[i])/2)

Ex = []
for j in range(0,len(P)-K+1):
  Ex.append(sum(E[j:j+K]))

print(max(Ex))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p_li = list(map(int,input().split()))
tmp = (sum(p_li[0:k])+k)/2
for i,p in enumerate(p_li):
    if i<k:
        continue
    if p_li[i]>p_li[i-k]:
        ans = (sum(p_li[i-k+1:i+1])+k)/2
        tmp = max(tmp,ans)
print(tmp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  p = input_list()
  kaku = []
  for v in p:
    kaku.append((1+v)/2)
  ans = []
  for i in range(len(p)-k+1):
    ans.append(sum(kaku[i:i+k]))
  print(max(ans))
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def expectation(n):
    return (n + 1) / 2


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    answer = 0
    for i in range(n - k + 1):
        tmp = 0
        for j in range(k):
            tmp += expectation(p[i + j])
        answer = max(answer, tmp)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

print((result+K)/2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int, input().split()))
L = []
S = [0]

for i in range(N):
    if P[i] % 2 == 0:
        L.append((P[i]+1)*(P[i]//2)*(1/P[i]))
    else:
        L.append(((P[i]+1)*(P[i]//2)+(P[i]//2+1))*(1/P[i]))
    S.append(sum(L))

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
P = list(map(int, input().split()))
L = []
for i in P:
    if i % 2 == 0:
        L.append((i+1)*(i//2)*(1/i))
    else:
        L.append(((i+1)*(i//2)+(i//2+1))*(1/i))
S = [0]
for i in range(N):
    S.append(sum(L[0:i+1]))
n = 0
for i in range(N-K+1):
    n = max(n,S[i+K]-S[i])
print(n)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
pn = list(map(int,input().split()))
num = 0
for i in range(N-K+1): num = max(num,sum(pn[i:i+K]))
print(0.5*K + num*0.5)

Submission status: Time Limit Exceeded

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

e_list = [(int(s) + 1) / 2 for s in input().split()]
e_sum_list = e_list[:]

for _ in range(k - 1):
    e_list.pop(0)
    e_sum_list = [a + b for a, b in zip(e_sum_list, e_list)]

ans = max(e_sum_list)
print(ans)

Submission status: Time Limit Exceeded

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

max_val = -1
max_pairs = None
for i in range(N-K+1):
    if sum(P[i:i+K]) > max_val:
        max_val = sum(P[i:i+K])
        max_pairs = P[i:i+K]

print(sum([(1+p)/2 for p in max_pairs]))

Submission status: Time Limit Exceeded

Solution code:
input_line=input().split(" ")
N,K=int(input_line[0]),int(input_line[1])
P=input().split(" ")

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

new_total_box=[]
for j in range(N-K+1):
    total=0
    for i in range(j,K+j):
        total=total+P[i]+1
    new_total_box.append(total)
    
max_value = max(new_total_box)


sol=max_value/2
    
print(sol)

Submission status: Time Limit Exceeded

Solution code:
import numpy
input_line=input().split(" ")
N,K=int(input_line[0]),int(input_line[1])
P=input().split(" ")

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



new_total_box=[]
for j in range(N-K+1):
    total=0
    for i in range(j,K+j):
        total=total+P[i]
    new_total_box.append(total)
    
max_value = max(new_total_box)
max_index = new_total_box.index(max_value)


total_box=[]
total=0
for i in range(max_index,max_index+K):
    total=total+(P[i]+1)/2
    
print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy
input_line=input().split(" ")
N,K=int(input_line[0]),int(input_line[1])
P=input().split(" ")

for i in range(N):
    P[i]=int(P[i])
expect=[]
for i in range(N):
    expect.append((P[i]+1)/2)

total_box=[]
for j in range(N-K+1):
    total=0
    for i in range(j,K+j):
        total=total+expect[i]
    total_box.append(total)
    
max_value = max(total_box)
max_index = total_box.index(max_value)
print(max_value)

Submission status: Time Limit Exceeded

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        select_list = []
        for j in range(K):
            select_list.append(p[i+j])

answer = 0
for i in select_list:
    answer += (1+i)/2
print(answer)

Submission status: Time Limit Exceeded

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        select_list = []
        for j in range(K):
            select_list.append(p[i+j])

answer = 0
for i in select_list:
    for pro in range(i):
        answer += (pro+1)*(1/i)
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

tmp=0
for i in range(K,N+1):
	t=sum(e[i-K:i])
	tmp=max(t,tmp)

print(tmp)

Submission status: Time Limit Exceeded

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


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

tmp=0
for i in range(K,N+1):
	tmp=max(sum(e[i-K:i]),tmp)

print(tmp)

Submission status: Time Limit Exceeded

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(0,k):
        e += (0.5*(p[i+j]+1))
    ans = max(ans,e)
print(ans)

Submission status: Time Limit Exceeded

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(0,k):
        e += (0.5*(p[i+j]+1))
    ans = max(ans,e)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np #pypy不可
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)
  if n%k == 0:
    r = k
    L = n
  else:
    r = n%k+1
    L = n+k-n%k
  chk = 0
  for _ in range(r):
    p.resize(L) # np.resize(p,L) にすると足りない分を繰り返す
    l = p.reshape(-1,k).sum(axis=1)
    #print(p.reshape(-1,k))
    m = max(l)
    chk = max(chk,m)
    p = np.delete(p,0)

  print((chk+k)/2)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)

chk = 0
for i in range(n-k+1):
  m = sum(p[i:k+i])
  chk = max(chk,m)

print((chk+k)/2)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n,k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)

chk = 0
for i in range(n-k+1):
  m = sum(p[i:k+i])
  chk = max(chk,m)
  if chk == m:
    a = p[i:k+i]

print((sum(a)+k)/2)