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:
N,K=map(int,input().split())
S=list(map(int,input().split()))

# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S)):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    try:
        t=S[i]-S[i+K]
    except IndexError:
        t=0
    if t<0:
        pass
    else:
        tempSKsum=sum(S[i:i+K])
        if maxSKsum<tempSKsum:
            maxSKsum=tempSKsum
            startSindex=i
        else:
            pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EV+=tempEV

print(EV)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=0

for i in range(len(S)):
    try:
        t=S[i]-S[i+K]
    except IndexError:
        t=0
    if t<0:
        pass
    else:
        tempsum=sum(S[i:i+K])
        if maxsum<tempsum:
            maxsum=tempsum
        else:
            pass

print(maxsum)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2)

maxsum=0

for i in range(len(S)):
    tempsum=sum(S[i:i+K])
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass

print(maxsum)

Submission status: Time Limit Exceeded

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

# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S)):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EV+=tempEV

print(EV)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
#from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = list(map(int,input().split()))

que = P[:K]
counter = []
counter.append(sum(que))
for k in range(K,N):
    que.pop(0)
    que.append(P[k])
    counter.append(sum(que))

print((max(counter)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = list(map(int,input().split()))

que = deque(P[:K])
counter = []
counter.append(sum(que))
for k in range(K,N):
    que.popleft()
    que.append(P[k])
    counter.append(sum(que))

print((max(counter)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = [(p+1)/2 for p in map(int,input().split()) ]

que = deque(P[:K])
counter = []
counter.append(sum(que))
for k in range(K,N):
    que.popleft()
    que.append(P[k])
    counter.append(sum(que))

print(max(counter))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
from collections import deque

#期待値はΣ(from 1 to pi)/len(pi)
P = [(p+1)/2 for p in map(int,input().split()) ]

que = deque(P[:K])
counter = sum(que)
for k in range(K,N):
    que.popleft()
    que.append(P[k])
    counter = max(counter,sum(que))

print(counter)

Submission status: Time Limit Exceeded

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


# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S)):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EV+=tempEV

print(EV)

Submission status: Time Limit Exceeded

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

# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S)):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=S[startSindex+s]*(S[startSindex+s]+1)/2/S[startSindex+s]
    EV+=tempEV

print(EV)

Submission status: Time Limit Exceeded

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

# K=4
# S=(17, 13, 13, 12, 15, 20, 10, 13, 17, 11)
# K=3
# S=[1,2,2,4,5]

# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S)):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

#2.1で探した大きい区間の計算をする。
EVlist=[]
for s in range(K):
    tempEV=S[startSindex+s]*(S[startSindex+s]+1)/2/S[startSindex+s]
    EVlist.append(tempEV)

print(sum(EVlist))

Submission status: Time Limit Exceeded

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

maxSKsum=0
startSindex=0

for i in range(len(S)):  #ここがrange(len(S)-K)ではダメないのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

EVlist=[]
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EVlist.append(tempEV)

print(sum(EVlist))

Submission status: Time Limit Exceeded

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

maxSKsum=0
startSindex=0

for i in range(len(S)):  #ここがrange(len(S)-K)ではダメないのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

EVlist=[]
for s in range(K):
    tempEV=S[startSindex+s]*(S[startSindex+s]+1)/2/S[startSindex+s]
    EVlist.append(tempEV)

print(sum(EVlist))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append(int(s))

# K=4
# S=[17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
# K=3
# S=[1,2,2,4,5]

maxSKsum=0
startSindex=0

for i in range(len(S)):
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

EVlist=[]
for s in range(K):
    tempEV=S[startSindex+s]*(S[startSindex+s]+1)/2/S[startSindex+s]
    EVlist.append(tempEV)

print(sum(EVlist))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append(int(s))

# K=4
# S=[17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
# K=3
# S=[1,2,2,4,5]

EVlist=[]

for i in range(len(S)):
    tempEV=(S[i]*(S[i]+1))/2/S[i]
    EVlist.append(tempEV)

maxEVsum=0

for j in range(len(EVlist)):
    tempEVsum=sum(EVlist[j:j+K])
    if maxEVsum<tempEVsum:
        maxEVsum=tempEVsum

print(maxEVsum)

Submission status: Time Limit Exceeded

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

m = 0
mi = 0

for i in range(N - K + 1):
    s = sum(p[i:i+K])
    if m < s:
        m = s
        mi = i

ans = (m + K) / 2

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

res = 0
i = 0
k = K
while k <= N:
  res = max(res, sum(exp[i:k]))
  i += 1
  k += 1

print(res)

Submission status: Time Limit Exceeded

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

exp = []
for p in P:
  if p in memo:
    exp.append(memo[p])
  else:
    cnt = p-1+1
    r = 0
    for i in range(1, p+1):
      r += i*(cnt**-1)
    exp.append(r)
    memo[p] = r

res = 0
i = 0
k = K
while k <= N:
  res = max(res, sum(exp[i:k]))
  i += 1
  k += 1

print(res)

Submission status: Time Limit Exceeded

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

exp = []
for p in P:
  cnt = p-1+1
  r = 0
  for i in range(1, p+1):
    r += i*(cnt**-1)
  exp.append(r)

res = 0
i = 0
k = K
while k <= N:
  res = max(res, sum(exp[i:k]))
  i += 1
  k += 1

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    p = LI()
    max_ans = 0
    max_i = 0
    ans = 0

    for i in range(0, N-K+1):
        sum_i = sum(p[i:i+K])
        #sum_i = p[i]
        #print("i",i)
        #for j in range(i+1,i+K):
        #    sum_i += p[j]
        #print("sum",sum_i)
        if max_ans <= sum_i:
            max_ans = sum_i
            max_i = i
    #print("max",max_i) 
    for j in range(max_i,max_i+K):
        #print("max_i",j)  
        ans += sum(range(1, p[j] + 1))/p[j]
    
    print(ans)




if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    p = LI()
    max_ans = 0
    max_i = 0
    ans = 0

    for i in range(0, N-K+1):
        sum_i = p[i]
        #print("i",i)
        for j in range(i+1,i+K):
            sum_i += p[j]
        #print("sum",sum_i)
        if max_ans <= sum_i:
            max_ans = sum_i
            max_i = i
    #print("max",max_i) 
    for j in range(max_i,max_i+K):
        #print("max_i",j)  
        ans += sum(range(1, p[j] + 1))/p[j]
    
    print(ans)




if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# 難易度 484
# 800~
# 解法805,pi~pjの合計が最大となる区間を求める
# Kの区間が固定されているので0~K-1 -> N-K~N-1を足していイケば良い
# 2~10^5こしかNがないので，せいぜいO(N)で終わるので十分
# 期待値の計算をいちいちしていたら，計算量がもタンクなるかも？最初から計算しておくか

N, K = map(int,input().split())
P = list(map(int,input().split()))
P_MAX = 10**3
E = [0]*(P_MAX+1)
for i in range(1,P_MAX+1):
    E[i] = sum([1/i * j for j in range(1,i+1)])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

maxp = 0
for i in range(n + 1 - k):
    e_temp = 0
    for j in range(k):
        e_temp += e_p[i + j]
    if e_temp > maxp:
        maxp = e_temp
print(maxp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

ans=M/2+K/2
print(ans)

Submission status: Time Limit Exceeded

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

best=0

for i in range(N-K+1):
    goukei=0
    for j in range(K):
        goukei+=S[i+j]
    if goukei>best:
        best=goukei
    
print((best+K)/2)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    c = sum(pp[i:i+k])
    if c > ans:
        ans = c


print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split())
P = list(map(int, input().split()))

max = 0
max_list = list()

for i in range(N - K + 1):
    sub = P[i:i+K]
    sum2 = sum(sub)

    if sum2 > max:
        max = sum2
        max_list = sub

ans = 0

for i in max_list:
    ans += 0.5 * (i + 1) 

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def kitai(n):
  return (n+1)/2
a,b=map(int,input().split())
L=list(map(int,input().split()))
maxa=10**10*(-1)
L=list(map(kitai,L))
for i in range(a-b+1):
  maxa=max(maxa,sum(L[i:i+b]))
print(maxa)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
for i in range(len(p)):
  l = p[i]
  p[i] = float((l+1)/2)
T = 0
for i in range(0,len(p)-K+1):
  t = p[i]
  for j in range(1,K):
    t += p[i+j]
  if t > T:
    T = t
print(T)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
res = 0
p = 0
for n in range(N):
    D = 0
    for k in range(K):
        O = 0
        O = sum(range(1, P[k]+1))
        D = D + (O / P[k])
    if res < D:
        res = D
    P.pop(0)
    if len(P) < K:
        break
print(res)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

num_of_dices, num_of_adjacents = map(int, input().split())
eyes = list(map(int, input().split()))
expected_values = []

for i, eye in enumerate(eyes):
    expected_values.append(sum(np.array(range(1, eye + 1)) / eye))

max_expected = 0

for i in range(num_of_dices - num_of_adjacents + 1):
    if max_expected < sum(expected_values[i:num_of_adjacents + i]):
        max_expected = sum(expected_values[i:num_of_adjacents + i])

print(max_expected)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    expect = (i+1)/2
    exp_list.append(expect)
answer = 0
for j in range(n-k+1):
    ans = 0
    for l in range(j, j+k):
        ans += exp_list[l]
    answer = max(answer, ans)
print(answer)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    prob = 1/i
    expect = 0
    for j in range(1, i+1):
        expect += j * prob 
    exp_list.append(expect)
answer = 0
for j in range(n-k+1):
    ans = 0
    for l in range(j, j+k):
        ans += exp_list[l]
    answer = max(answer, ans)
print(answer)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    prob = 1/i
    expect = 0
    for j in range(1, i+1):
        expect += j * prob 
    exp_list.append(expect)
answer = 0
for j in range(n-k+1):
    ans = 0
    for l in range(j, j+k):
        ans += exp_list[l]
    answer = max(answer, ans)
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

n,k = map(int,input().split())
p = list(map(int,input().split()))
ave = deque([])
ans = 0

for i in range(n):
  ave.append((p[i]+1)/2)
  if len(ave) == k:
    ans = max(ans,sum(ave))
    ave.popleft()


print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ave = []
ans = 0
s = 0

for i in range(n):
  ave.append((p[i]+1)/2)

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

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n):
  ave.append((p[i]+1)/2)

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

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):
    ans = max(ans, sum(p[i:i+k]))

print((ans+k)/2)

Submission status: Time Limit Exceeded

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

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

print((m+k)/2)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    a = sum(p[i:i+k])
    l.append(a)

print((max(l) + k)/2)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    a = sum(p[i:i+k])
    if a > highest:
        highest = a

print((highest + k)/2)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    a = sum(p[i:i+k])
    if a > highest:
        highest = a

print((highest + k)/2)

Submission status: Time Limit Exceeded

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

for l in range(n-k+1):
  ans=max(ans,(k+sum(p[l:l+k]))/2)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
maxv = 0
for i in range(n):
	maxv = max(maxv, sum(P[i:i+k]))
print((maxv + k) * 0.5)

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
n, k = map(int, input().split())
P = list(map(int, input().split()))
for i in range(len(P)):
	P[i] = (P[i] + 1) * 0.5
maxv = 0
for i in range(n):
	maxv = max(maxv, sum(P[i:i+k]))
print(maxv)

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

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

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

print(max(ans))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

expected = []
for val in p_l:
    expected.append((val+1)/2)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
ps =[0] + list(accumulate(p))
a = 0
b = []
for i in range(n+1- k):
    if a < ps[i+k] - ps[i]:
        a = ps[i+k] - ps[i]
        b = p[ i : i + k ]
        
x = 0
for i in b:
    for j in range(i+1):
        x += j/i
print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
kitaiti = [0]*N
for i,c in enumerate(p):
    kitaiti[i] = ((0.5*c*(c+1))/c)
if K == 1:
    print(max(kitaiti))
else:
    temp = [0,0]
    temp2 = sum(kitaiti[0:K])
    for i in range(1,N-K+1):
        temp3 = sum(kitaiti[i:i+K])
        if temp2 < temp3:
            temp2 = temp3
    print(temp2)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
for i in range(len(p)-k+1):
  t=p[i:i+k]
  s.append(t)
#print(s)
ans=0
for i in range(len(s)):
  sums=0
  for j in range(k):
    sums+=(s[i][j]+1)*s[i][j]/2/s[i][j]
  #print(sums)
  ans=max(ans,sums)
print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[]
for i in range(len(p)-k+1):
  t=p[i:i+k]
  s.append(t)
#print(s)
ans=0
for i in range(len(s)):
  sums=0
  for j in range(k):
    sums+=(s[i][j]+1)*s[i][j]/2/s[i][j]
  #print(sums)
  ans=max(ans,sums)
print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

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

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

def solve(N: int, K: int, P: "List[int]"):
    largest = 0
    if K == 1:
        largest = expectation(max(P))
        print(largest)
        return

    for i, p in enumerate(P[:-K+1]):
        summation = 0
        for k in range(K):
            summation += expectation(P[i + k])

        if summation > largest:
            largest = summation

    print(largest)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, P)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n,k = [int(x) for x in input().split()]
arr = [int(j) for j in input().split()]
pre = [0 for x in range(len(arr)+1)]
maxi = -1
m = 0
for x in range(n):
    for x in range(0,n+1):
        if x != n:
            pre[x+1] = pre[x] + arr[x]

        if x-k >= 0:
            if pre[x] - pre[x-k] > m:
                m = pre[x] - pre[x-k]
                maxi = x-k
ex = 0 
for x in range(maxi, maxi+k):
    ex += (arr[x]+1)/2;

print(ex)

Submission status: Time Limit Exceeded

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

ex = 0 

a = 0

pre = [0 for x in range(len(arr)+1)]
for x in range(0,n):
    pre[x+1] = pre[x] + arr[x]

maxi = -1
m = 0
for j in range(k, n+1):
    if pre[j] - pre[j-k] > m:
        m = pre[j] - pre[j-k]
        maxi = j-k

for x in range(maxi, maxi+k):
    for j in range(1, arr[x]+1):
        ex += j/arr[x]

print(ex)

Submission status: Time Limit Exceeded

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

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


ans = []
curr_max = 0
for i in range(N - 1, K - 2, -1):
    curr_vals = p[i - K + 1:i + 1]
    if sum(curr_vals) >= curr_max:
        curr_max = sum(curr_vals)
        ans = curr_vals

print("{}".format(sum(list(map((lambda x: expect_val(x)), ans)))))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
mx = 0
mx_list = []
for i in range(N-K+1):
    if sum(p[i:i+K]) > mx:
        mx = sum(p[i:i+K])
        mx_list = p[i:i+K]
ans = 0
for i in mx_list:
    ans += (i+1)/2
print('{:.20f}'.format(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):
    kitaichi = 0
    for j in range(i, i+K):
        kitaichi += (p[j]+1)/2
    ans = max(ans, kitaichi)
print("{:.20f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    ans = -float("inf")
    ans = max([sum(ps[i:i+k]) for i in range(n-k+1)])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    ans = -float("inf")
    for i in range(n-k+1):
        ans = max(ans, sum(ps[i:i+k]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in range(len(P)-K+1):
    B.append(sum(P[i:i+K]))
        
A = B.index(max(B))
print(sum(P[A:A+K])/2+0.5*K)

Submission status: Time Limit Exceeded

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

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

answer = 0

for a in A:
    answer += a/2+0.5

print(answer)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
B = []
result = []
for a in P:
    B.append(a/2+0.5)

for i in range(len(P)-K+1):
    result.append(sum(B[i:i+K]))

print(max(result))

Submission status: Time Limit Exceeded

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

for i in range(len(A)-K+1):
    t = sum(A[i:i+K])
    ans = max(ans,t)

print((ans+K)/2)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = list(map(int,input().split()))
check = [0]*1001
tmp_p = []
for p in P:
    if check[p]!=0:
        tmp_p.append(check[p])
    else:
        tmp = ((1+p)*p/2)/p
        tmp_p.append(tmp)
ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(tmp_p[i:k+i]))
print(ans)

Submission status: Time Limit Exceeded

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

tmp_p = []
for p in P:
    tmp = ((1+p)*p/2)/p
    tmp_p.append(tmp)
ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(tmp_p[i:k+i]))
print(ans)

Submission status: Time Limit Exceeded

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

l = list(map(int, input().split()))
l = [(i+1)/2 for i in l]

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

print(m)

Submission status: Time Limit Exceeded

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

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

le = [(i+1)/2 for i in l]

ls = list()
for i in range(n-k+1):
    ls.append(sum(le[i:i+k]))

print(max(ls))

Submission status: Time Limit Exceeded

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


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

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

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

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    p = np.array(p, dtype='f8')
    p = (p + 1) / 2

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

    print(ans)


if __name__ == '__main__':
    solve()

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())))
M = 0
for i in range(n - k + 1):
    M = max(M,P[i:i + k].sum())

ans = (M + k) / 2
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())))
A = np.array([])
for i in range(n - k + 1):
    A = np.append(A,P[i:i + k].sum())

M = np.max(A)
ans = (M + k) / 2
print(ans)

Submission status: Time Limit Exceeded

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

M = max(A)
ans = (M + k) / 2
print(ans)

Submission status: Time Limit Exceeded

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

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

kl = []

mx = 0

while len(s) >= k:
    b = s[0:k]
    d = sum(b)
    
    if d >= mx:
        mx = d
        c = b
        
    s.pop(0)
    
# print(c)

kitai = 0

for i in range(len(c)):
    
    kitai += (c[i] + 1) * (c[i] / 2) / c[i]
    # kl.append(kitai)
print(kitai)

Submission status: Time Limit Exceeded

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

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

kl = []

mx = 0

for i in range(len(s)):
    kitai = (s[i] + 1) * (s[i] / 2) / s[i]
    kl.append(kitai)
    
    if len(kl) == k:
        d = sum(kl)
    
        if d >= mx:
            mx = d
            
        kl.pop(0)
    

print(mx)