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:
def kitai(P):
    kitai = 0
    for i in range(len(P)):
        for j in range(1, P[i]+1):
            kitai += j / P[i]
    return kitai

N, K = map(int, input().split())
P = [int(x) for x in input().split()]
ans = 0
for i in range(K-1, N):
    ans = max(kitai(P[i-K+1:i+1]), ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
last_sum = -1
sum_k = 0
s = 0
for i in range(n - k + 1):
    for j in range(0, k):
        for u in range(1, p[i + j] + 1):
            s += u
        sum_k += s * (1 / p[i + j])
        s = 0
    if last_sum < sum_k:
        last_sum = sum_k
    sum_k = 0
print("{:.7f}".format(last_sum))

Submission status: Time Limit Exceeded

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

e_max = 0

for i in range(n - k + 1):
    e = 0
    for j in range(k):
        e += p[i+j]
    if e > e_max:
        e_max = e

r = e_max/2 + (0.5 * k)
print(str(r))

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):
  sum = 0
  for j in range(i,i+K):
    sum += (P[j]+1)/2
    m = max(m, sum)
print(m)

Submission status: Time Limit Exceeded

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

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

print(max(e))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
num, key = list(map(int, input().split()))
dice = list(map(int, input().split()))
sum, start = 0, 0
for i in range(num-(key-1)):
  tmp = 0
  for j in range(i,i+key):
    tmp += dice[j]
  if tmp>sum:
    start = i
    sum = tmp

sum, tmp = 0, 0
for i in range(start, start+key):
  tmp = 0
  for j in range(dice[i]):
    tmp += (j+1)/dice[i]
  sum += tmp
print(sum)

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(N-K+1):
    mx = sum(P[i:i+K]) if sum(P[i:i+K])>mx else mx

print((mx+K)/2.)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
P =[]
max_l = 0
max_v = 0
P = list(map(int, input().split()))
for i, p in enumerate(P):
  if i <= N-K:
    #print(P[i:K+i])
    if max_v < sum(P[i:K+i]):
      max_v = sum(P[i:K+i])
      
      max_l = P[i:K+i]
#print(max_v)
ans = 0
for l in max_l:
  ans += (l+1)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
P =[]
max_l = 0
max_v = 0
P = list(map(int, input().split()))
for i, p in enumerate(P):
  if i <= N-K:
    #print(P[i:K+i])
    if max_v < sum(P[i:K+i]):
      max_v = sum(P[i:K+i])
      
      max_l = P[i:K+i]
#print(max_v)
ans = 0
for l in max_l:
  ans += (l+1)*l/2/l
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        for i in range(n-k+1):
            cal = sum(p1[i:i+k])
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Submission status: Time Limit Exceeded

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

exp = []
for i in range(1, N + 1):
    # i=1
    exp.append(sum(range(1, P[i - 1] + 1)) / P[i - 1])

max = 0
for i in range(N - K + 1):
    val = sum(exp[i:i + K])
    if val > max:
        max = val

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
input_data = input().split()
data = [int(n) for n in input_data]
data_exp = []
for d in data:
    data_exp.append(1 + (d-1)/2)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
input_data = input().split()
data = [int(n) for n in input_data]

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

print(ans)

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(N - K + 1)) + 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):
  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()))

iter_num = n - k + 1

ans = []
for i in range(iter_num):
	ans.append((sum(p[i:k+i])+k)/2)

print(max(ans))

Submission status: Time Limit Exceeded

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

exmax=0

for i in range(n-k+1):
	ex=0
	for j in range(k):
		ex+=plist[i+j]
	if (ex+k)/2 > exmax:
		exmax=(ex+k)/2

print(exmax)

Submission status: Time Limit Exceeded

Solution code:
n , k = map(int, input().split())
p = list(map(int, input().split()))
size = max(p)
sheet = [0]*size
for i in range(size):
    if (i == 0):
        sheet[i]=1
    else:
        sheet[i] = (sheet[i-1]*i + (i+1))/(i+1)
ans = 0
for i in range(n-k+1):
    total = 0
    for j in range(k):
        total += sheet[p[i+j]-1]
    if (total > ans):
        ans = total
print (ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
sum1 = 0
sumMax = 0
for i in range(N-K+1):
    for j in range(K):
        sum1 = sum1 + p[i+j]
    if(sumMax < sum1):
        sumMax = sum1
    sum1 = 0
result = 0.5*K + 0.5*(sumMax)
print(result)

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n, k = (int(x) for x in stdin.readline().rstrip().split())
p = [int(x) for x in stdin.readline().rstrip().split()]
ev = [((i*(i+1))/2)/i for i in p]

m = 0
for i in range(n-k+1):
    a = [ev[x] for x in range(i, i+k)]
    if m < sum(a):
        m = sum(a)

print(m)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n, k = (int(x) for x in stdin.readline().rstrip().split())
p = [int(x) for x in stdin.readline().rstrip().split()]

m = 0
s = 0
total = 0
for i in range(n-k+1):
    a = sum([p[i+x] for x in range(k)])
    if m <= a:
        m = a
        s = i

for i in range(k):
    b = sum([x for x in range(1, p[s+i] + 1)])
    total += b/p[s+i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
expected_value_dic = {}

def get_expected_value(x):
    return (1 + x) / 2

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

P = list(map(int, input().split()))
expected_values = [get_expected_value(p) for p in P]

selected_array = [expected_values[i] for i in range(k)]
max_sum = sum(selected_array)
for i in range(k, len(P)):
    del selected_array[0]
    selected_array.append(expected_values[i])
    array_sum = sum(selected_array)
    if array_sum > max_sum:
        max_sum = array_sum


print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
expected_value_dic = {}

def get_expected_value(x):
    if x in expected_value_dic:
        return expected_value_dic[x]
    result = 0
    for i in range(1, x+1):
        result += i / x
    expected_value_dic[x] = result
    return result

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

P = list(map(int, input().split()))
expected_values = [get_expected_value(p) for p in P]

selected_array = [expected_values[i] for i in range(k)]
max_sum = sum(selected_array)
for i in range(k, len(P)):
    del selected_array[0]
    selected_array.append(expected_values[i])
    array_sum = sum(selected_array)
    if array_sum > max_sum:
        max_sum = array_sum


print(max_sum)

Submission status: Time Limit Exceeded

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

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())))
p = (p+1)/2

ans,i = 0,0
while i+K <= N:
    psum = sum(p[i:i+K])
    if psum > ans:
        ans = psum
    i += 1

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] = 0.5*(p[i]+1)

ans,i = 0,0
while i+K <= N:
    psum = sum(p[i:i+K])
    if psum > ans:
        ans = psum
    i += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import decimal

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

exps = []
for i in l1:
    a_exp = 0
    if i % 2 ==0:
        a_exp = (1+i)/float(2)
    else:
        a_exp = i//2+1
    exps.append(a_exp)

sums = []
for i in range(n-k+1):
    a_sum = 0
    for j in range(k):
        a_sum += exps[i+j]
    sums.append(a_sum)
    
print(max(sums))

Submission status: Time Limit Exceeded

Solution code:
import decimal

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

exps = []
for i in l1:
    s = 0
    for j in range(1,i+1):
        s = s + j
    a_exp = s/float(i)
    exps.append(a_exp)

sums = []
for i in range(n-k+1):
    a_sum = 0
    for j in range(k):
        a_sum += exps[i+j]
    sums.append(a_sum)
    
print(max(sums))

Submission status: Time Limit Exceeded

Solution code:
import decimal

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

exps = []
for i in l1:
    s = 0
    for j in range(1,i+1):
        s = s + j
    a_exp = decimal.Decimal(s/i)
    exps.append(a_exp)

sums = []
for i in range(n-k+1):
    a_sum = 0
    for j in range(k):
        a_sum += exps[i+j]
    sums.append(a_sum)
    
print(max(sums))

Submission status: Time Limit Exceeded

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

maximum = 0
for i in range(N - K + 1):
    ans = sum(p[j] for j in range(i,i + K))
    if ans >= maximum:
        maximum = ans
maximum = (maximum + K) / 2
print(maximum)

Submission status: Time Limit Exceeded

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

maximum = 0
for i in range(N - K + 1):
    ans = 0
    for j in range(K):
        ans += (p[i + j] + 1) / 2
    if ans >= maximum:
        maximum = ans
print(maximum)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(lambda i: (i + 1) / 2, list(map(int, input().split()))))
# print(p)
lists = [sum(p[i:i + k]) for i in range(n - k + 1)]
print('{0:.10f}'.format(max(lists)))

Submission status: Time Limit Exceeded

Solution code:
def summm(a):
    ans = 0
    for i in a:
        ans += (i + 1) / 2
    return ans

n, k = map(int, input().split())
p = list(map(int, input().split()))
lists = [summm(p[i:i + k]) for i in range(n - k + 1)]
print('{0:.10f}'.format(max(lists)))

Submission status: Time Limit Exceeded

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

for i in range(n - k + 1):
    sump.append(sum(p[i: k + i], k))
print(max(sump) / 2)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
B=[]
C=[]
D=[]
for i in range(n):
  C.append((1+A[i])/2)
  B.append(sum(C))
  if i>=k:
    D.append(B[i]-B[i-k])
  elif i==k-1:
    D.append(B[i])
print(max(D))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
num=list(map(float,input().split()))
answer=[]
a=0
for i in range(N):
    num[i]=(num[i]+1)/2
for i in range(N-K+1):
    ans=0
    for j in range(K):
        ans+=num[i+j]
    if ans>a:
      a=ans
print(a)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
num=list(map(float,input().split()))
#print(num)
answer=[]
for i in range(N):
    num[i]=(num[i]+1)/2
for i in range(N-K+1):
    ans=0
    for j in range(K):
        ans+=num[i+j]
    answer.append(ans)
a=max(answer)
print(a)

Submission status: Time Limit Exceeded

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

for i in range(n-k+1):
    pListSlice = pList[i:k+i]
    sumA = (sum(pListSlice) + k)/2
    if sumA > pListMax:
        pListMax = sumA
print(pListMax)

Submission status: Time Limit Exceeded

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

for i in range(n):
    pList[i] = (pList[i] + 1) / 2

for i in range(n-k+1):
    pListSlice = pList[i:k+i]
    if sum(pListSlice) > pListMax:
        pListMax = sum(pListSlice)
print(pListMax)

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]=sum(range(P[i]+1))/P[i]

s=[]
for i in range(n-k+1):
    s.append(sum(P[i:i+k]))

print(max(s))

Submission status: Time Limit Exceeded

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

maxe = 0


for i in range(n-k+1):
   e = 0
   for j in range(i, i+k):
      e += sum([k for k in range(1, p[j]+1)])/p[j]

   maxe = max(maxe, e)

print(maxe)

Submission status: Time Limit Exceeded

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

p = [int(s) for s in input().split()]
t = 0
for x in range(n-k+1):
  if sum(p[x:x+k]) >= t:
    t = sum(p[x:x+k])

print((t+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()))
p = np.array(p)

res = np.convolve(p, [1]*k, mode='valid')
ans = (np.max(res)+k*1)/2
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def wa(n):
    if n<=1:
        return 1
    else:
        return wa(n-1)+n

if __name__ == "__main__":
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    b=[]
    for i in a:
        b.append((i+1)/2)
    max=0
    for i in range(len(b)-k+1):
        sum=0
        for j in range(i,i+k):
            sum+=b[j]
        if max<=sum:
            max=sum
    print(max)

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())))
def kitaichi(a):
  s=(1+a)/2.
  return s
kp=kitaichi(p)
buf=np.zeros(len(kp))
for z in range(0,k):
  buf[:n-z]=buf[:n-z]+kp[z:]
maxkp=buf[:n-k+1].max()
print(maxkp)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    (N, K) = map(int, inp.readline().strip().split(' '))
    P = list(map(int, inp.readline().strip().split(' ')))

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

    result = 0.0
    for i in range(mi, mi + K):
        s = 0
        for j in range(1, P[i] + 1):
            s += j
        result += s / P[i]

    return str(result)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

max_kitai = 0
for i in range(N - K + 1):
    res = sum(P_kitai[i:i+K])
    max_kitai = max(max_kitai, res)
print(max_kitai)

Submission status: Time Limit Exceeded

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

def kitai(n):
    return (1+n) /2

temp = 0

for i in range(N-K+1):
    add = 0
    for j in range(K):
        add += kitai(p[i+j])
    if temp < add:
        temp = add
        
        
print(temp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#D
N, K = map(int, input().split())
p= [int(x) for x in input().split()]
ap = p
ans = 0
for i in range(N):
    ap[i] = (p[i]+1)/2
for i in range(N-K+1):
    now = 0
    for j in range(K):
        now += ap[i+j]
    ans = max(ans, now)

print (ans)

Submission status: Time Limit Exceeded

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

res = -1

for i in range(N):
    p[i] = (p[i]+1)/2
    if i+1 < K:
        continue
    val = sum(p[i+1-K:i+1])
    if val > res:
        res = val

print(res)

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)):
    p[i] = (p[i]+1)/2

res = -1

for i in range(N):
    if i+1 < K:
        continue
    val = sum(p[i+1-K:i+1])
    if val > res:
        res = val

print(res)

Submission status: Time Limit Exceeded

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

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())))
l=2

sum_max=0
for l in range(N-K+1):
    sum=P[l:l+K].sum() 
    if(sum>=sum_max):
        sum_max=sum

print(K*0.5+0.5*sum_max)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
# dp = [0] * n

dp = [(i + 1)/2 for i in pl]
pmax = [0] * (n-k+1)

for i in range(n-k+1):
    pmax[i] = sum(dp[i:i+k])

print(max(pmax))

Submission status: Time Limit Exceeded

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

pmax = 0
for i in range(n-k+1):
    psum = sum(dp[i:i+k])
    if pmax < psum:
        pmax = psum

print(pmax)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    n, k = map(int, input().split())
    p = np.array(list(map(int, input().split())))
    e = np.array([(k + (p[j-1:j+k-1].sum())) / 2. for j in range(1, n-k+2)])
    ans = e.max()
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    e = []
    for j in range(1, n-k+2):
        e.append((k + (sum(p[j-1:j+k-1]))) / 2.)
    ans = max(e)
    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()))

def kitaiti(num):
    result = (num+1)*num/(num*2)
    return result
r = [kitaiti(p[i]) for i in range(n)]

result = []
for i in range(n-k+1):
    result.append(sum(r[i:i+k]))
print(max(result))

Submission status: Time Limit Exceeded

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

m = max(p)
l = [0]
for i in range(1,m + 1):
    l.append(l[-1] + i)
for i in range(1,len(l)):
    l[i]/=i
for i in range(n):
    p[i] = l[p[i]]

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

n, k = map(int, input().split())
p_n = [int(i) for i in input().split()]

def expected(x):
    return (x+1)/2

e_n = list(map(expected, p_n))
result = []
for i in range(n-k+1):
    window_total = 0
    for j in range(k):
        window_total +=e_n[i+j]
    result.append(window_total)
print(max(result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
kitai_li=[]
for i in range(n):
    ki=0
    for j in range(0,p[i]+1):
        ki+=j
    kitai=ki/p[i]
    kitai_li.append(kitai)
ans_li=[]
for i in range(n-k+1):
    ans=sum(kitai_li[i:i+k])
    ans_li.append(ans)
print(max(ans_li))

Submission status: Time Limit Exceeded

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

def hoge(P, x, K):
  l = P[x:x+K]+ [K]
  return l
  
answer = max([sum(hoge(P,x,K))*0.5 for x in range(N-K+1)])
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

e = lambda p: (1+p)/2 #期待値

#期待値の配列
exp=[e(p[0])]
for i in range(1,n):
    tmp=exp[i-1]+e(p[i])
    exp.append(tmp)
    
#累積和
subsum=[]
for i in range(n-k+1):
    subsum.append(sum(p[i:k+i]))
    
#累積和の最大値のインデックス
idx = subsum.index(max(subsum))

if idx==0: print(exp[k-1])
else: print(exp[(idx-1)+k]-exp[(idx-1)])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

t = 0
A = []

for i in range(n-k+1):
    s = sum(P[i:i+k])
    if s > t:
        A = P[i:i+k]
        t = s
ans = 0
def f(x):
    y = 0
    for i in range(x+1):
        y += i
    return y / x

B = []
C = []
for i in A:
    if i not in B:
        temp = f(i)
        B.append(i)
        C.append(temp)
    else:
        temp = C[B.index(i)]
    ans += temp
print(ans)

Submission status: Time Limit Exceeded

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

exp = []
sum_list = [0]
result_list = []
result = 0
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    tmp = sum_list[K+i] - sum_list[i]
    if result < tmp:
        result = tmp
    
print(result)

Submission status: Time Limit Exceeded

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

exp = []
sum_list = [0]
result_list = []
for i in range(N):
    exp.append((p[i]+1)/2)
    sum_list.append(sum(exp))  
for i in range(N-K+1):
    result_list.append(sum_list[K+i] - sum_list[i])
print(max(result_list))

Submission status: Time Limit Exceeded

Solution code:
def exp(x):
  ans = 0
  for i in range(x+1):
    ans += i
  return ans / x

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

for i in range(n-k):
  sum += exp(p[i+k]) - exp(p[i])
  if max < sum:
    max = sum

print(max)

Submission status: Time Limit Exceeded

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

exp = []
for i in range(N):
    exp.append((p[i]+1)/2)    
sum_list = []
for i in range(N-K+1):
    sum_list.append(sum(exp[i:K+i]))
print(max(sum_list))

Submission status: Time Limit Exceeded

Solution code:
def exp(x):
  ans = 0
  for i in range(x+1):
    ans += i
  return ans / x

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

for i in range(n-k):
  sum -= exp(p[i])
  sum += exp(p[i+k])
  ans.append(sum)

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
def exp(x):
  ans = 0
  for i in range(x+1):
    ans += i
  return ans / x

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

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
def exp(x):
  ans = 0
  for i in range(x+1):
    ans += i
  return ans / x

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

e = []
for i in range(n):
  e.append(exp(p[i]))
  
ans = []
for i in range(n-k+1):
  sum = 0
  for j in range(k):
    sum += e[i+j]
  ans.append(sum)

print(max(ans))