Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()
p = read_int()

def solve():
    ans = 0
    for h in range(N - K + 1):
        partial = 0
        for i in range(h, h + K):
            partial += (p[i] + 1) / 2
        ans = max(ans, partial)
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Time Limit Exceeded

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

maxlist = sum(numlist[0:K])
max_num = 0
for i in range(N-K+1):
  a = sum(numlist[i:i+K])
  if a >= maxlist:
    maxlist = a
    max_num = i

definelist = numlist[max_num:max_num+K]
expected = 0
for j in definelist:
  dice = list(range(1, j+1))
  ex = 0
  p = 1/len(dice)

  for x in dice:
    px = p*x
    ex += px
  expected += ex

print(expected)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, K = fetch_int_input()
p = fetch_int_input()

tmp_nums = p[0: K]
max_nums = p[0: K]
max_num = sum(tmp_nums)

for i in range(N - K + 1):
    tmp_nums.pop(0)
    tmp_nums.append(p[i + K - 1])
    sum_nums = sum(tmp_nums)

    if max_num < sum_nums:
        max_num = sum_nums
        max_nums = tmp_nums[:]


ave_nums = [(i + 1) / 2 for i in max_nums]

print(sum(ave_nums))

Submission status: Time Limit Exceeded

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

max_val = 0
for ind in range(n-k+1):
  cur_val = sum(p[ind:ind+k])
  max_val = max(max_val,cur_val)
max_val = float(max_val)
k = float(k)
print(max_val/2+k/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0

for i in range(n-d+1):
  Sum = sum(a[i:i+d])
 
  if Sum >= Max:
    Max = Sum
    ans = a[i:i+d]    
  else:
    pass
  
ans = np.array(ans)
ans = ans*0.5 + 0.5
print(sum(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_nums = 0
for idx in range(0, len(nums)-K+1):
    if sum(nums[idx:idx+K]) > max_nums:
        max_nums = sum(nums[idx:idx+K])
        max_list = nums[idx:idx+K]

kitai = 0

for num in max_list:
    kitai += (num+1)/2

print(kitai)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
val_list = []
val_num = N - K + 1
max_sum = 0
max_index = 0
for i in range(val_num):
    val = sum(p_list[i:i+K])
    if val > max_sum:
        max_sum = val
        max_index = i

result = (max_sum + K) / 2
print(result)

Submission status: Time Limit Exceeded

Solution code:
def get_expect(p):
    return 1.0 * (p + 1) / 2

def main():
    N, K = map(int, input().split(" "))
    P = list(map(int, input().split(" ")))
    print(max([
        sum([
            get_expect(p)
            for p in P[i:i + K]
        ])
        for i in range(N - K + 1)
    ]))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

x=sum(P[:K])

for i in range(N-K+1):
    t=sum(P[i:i+K])
    if t>x:
        x=t
        
print(x)

Submission status: Time Limit Exceeded

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

ans=0
for i in range(n-k+1):
  tmp=0
  for j in range(k):
    tmp+=(p[i+j]+1.0)/2.0
  ans = max(ans, tmp)
print('{:.12f}'.format(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())))

def expect(ps,k):
    return sum((ps + 1)/2)

ans = 0
for i in range(n-k+1):
    ps = p[i:(i+k)]
    ans = max(ans,expect(ps,k))


print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(num) for num in input().split(' ')]
As = [int(num) for num in input().split(' ')]

max_ = -1.0
window = []

for i in range(K):
	A = As[i]
	window.append(float((1+A)/2.0))
	if max_ < sum(window):
		max_ = sum(window)
	

for j in range(K,N):
	window.pop(0)
	A = As[j]
	sum_ = float((1+A)/2.0)
	window.append(sum_)
	if max_ < sum(window):
		max_ = sum(window)

print(max_)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
e = [sum([ j for j in range(1, P[i]+1)]) / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))
    expected = max([sum([(x + 1) / 2 for x in ps[left: left + K]]) for left in range(N - K + 1)])
    print(expected)

solve()

Submission status: Time Limit Exceeded

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

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

ans = 0

for i in range(N - K + 1):
    tmp = sum(p[i:i + K])
    if ans < tmp:
        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()))
s_max = 0
max_i=0
ret = 0
s_list = [sum(p[i:i+k]) for i in range(n-k+1)]
s_max=max(s_list)
print(k/2+s_max/2)

Submission status: Time Limit Exceeded

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

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for j in range(i - K + 1, i + 1):
        tmp_kitai = 0
        for k in range(p[j]):
            tmp_kitai += (k + 1)
        tmp_kitai = tmp_kitai / p[j]
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

Submission status: Time Limit Exceeded

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

n, k = int(n), int(k)

ans = 0

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


print(ans / 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):
  l.append(sum(p[i:i+K]))
t=l.index(max(l))
b=[]
for i in range(K):
  a=sum(range(1,p[t+i]+1))/p[t+i]
  b.append(a)
print(sum(b))

Submission status: Time Limit Exceeded

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


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
[n,k] = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
ls = [0]
ex = [0]
mx = 1001
for i in range(1,mx):
    ls.append(i + ls[i-1])
for i in range(1,mx):
    ex.append(ls[i]/i)
a = []
for i in range(n):
    a.append(ex[p[i]])
#print(a)
ans = -1
ruiseki = []
for i in range(n-k+1):
    ruiseki.append(sum(a[i:i+k]))
print(max(ruiseki))

Submission status: Time Limit Exceeded

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

s=0

for i in range(N):
    t=(L[i]+1)*L[i]/2*(1/L[i])
    A[i]=t

for i in range(N-K+1):
    #print(A[i:i+K])
    s=max(s,sum(A[i:i+K]))

print(s)

Submission status: Time Limit Exceeded

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

def P(n):
  return n * (n+1)/2/n

set_p = list(set(p))
dice = []
for x in range(len(set_p)):
  dice.append(P(set_p[x]))

ans = 0
for i in range(N - (K - 1)):
  a = 0
  for j in range(K):
    n = set_p.index(p[i + j])
    a += dice[n]
  if a > ans:
    ans = a

print(ans)

Submission status: Time Limit Exceeded

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

a = 0
b = 0
c = 0

for i in range(N-K+1):
  for j in range(K):
    a += p[i+j]
  b = max(a, b)
  a = 0
    
ans = (b + K) / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
#print(N,K)
mylist= list(map(int, input().split()))
tempmax=0
templist=[]
answer=0

for i in range(N-K+1):
    templist=mylist[i:i+K]
    #print(templist)
    tempmax=sum(templist)
    
    if  answer<tempmax:
        answer=tempmax
        
print((answer+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
for num in p:
    elm = (num * (num + 1) / 2) * (1 / num)
    nums.append(elm)
maxVal = 0
for i in range(n - k + 1):
    if sum(nums[i: i + k]) >= maxVal:
        maxVal = sum(nums[i: i + k])
    else:
        continue
print(maxVal)

Submission status: Time Limit Exceeded

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

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

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mydata = []

kazu = list(range(1,1001))
for i in p_L:

    kitai = sum(kazu[0:i])/i
    mydata.append(kitai)



res = [0] * (n+1)

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

# print(mydata)
# print(res)
# print("----")
ans = 0
for i in range(n-k+1):
    ans = max(ans,sum(mydata[i:i+k]))
    #print(mydata[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 = -1
for i in range(N-K+1):
    sum = 0
    for j in range(K):
        tmp = P[i+j]
        sum += tmp - 0.5*(tmp-1)
    
    ans = max(ans, sum)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def sums(N):
  res = 0
  for i in range(1, N+1):
    res += i
  return res

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



exp = [0 for _ in range(N)]
for i in range(0, N):
  exp[i] = sums(Ps[i])/Ps[i]

ans = [0 for _ in range(N)]

for i in range(0, K):
  ans[K-1] += exp[i]

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


print(ans[N-1])

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache

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


@lru_cache(maxsize=None)
def calc_exp(n: int):
    return sum(range(1, n + 1)) / n


len_sum = -1
max_len = None
for i in range(len(P)):
    if len(P[i:i + K]) == K:
        l = sum(P[i:i + K])
        if l > len_sum:
            max_len = P[i:i + K]
            len_sum = sum(max_len)

print(sum(map(calc_exp, max_len)))

Submission status: Time Limit Exceeded

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

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

p = list(map(int,input().split()))
E_lis = [E(i) for i in p]
res = []

for i in range(len(p)-k+1):
    temp = 0
    for j in range(k):
        temp += E_lis[i+j]
    res.append(temp)
print(max(res))

Submission status: Time Limit Exceeded

Solution code:
def e(a,b):
    x=(a+b)/2
    return x
ans=0
Max=0
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n-k+1):
    tmp=0
    for j in range(i,i+k):
        tmp+=l[j]
        Max=max(tmp,Max)
print(e(Max,k))

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def dice():
    n, k = map(int, input().split())
    p = np.asarray(list(map(int, input().split())))
    pp = np.zeros(n)
    for i in range(n):
      pp[i] = p[i]*(p[i]+1)/(2*p[i])

    ans = 0
    for i in range(n-k+1):
        tmp = sum(pp[i:i+k])
        if ans < tmp:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    dice()

Submission status: Time Limit Exceeded

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

def expectation(pp):
    return 1 + (0.5 * (pp - 1))

p = list(map(int, input().split()))
ep = tuple(map(expectation, p))

# print(ep)

# print(ep[0:K])

tmp_sum = sum(ep[0:K])
save_sum = tmp_sum

for i in range(1, N - K + 1):
    tmp = ep[i : i + K]
    tmp_sum -= ep[i - 1]
    tmp_sum += tmp[K - 1]
    save_sum = max(tmp_sum, save_sum)
    
print(save_sum)

Submission status: Time Limit Exceeded

Solution code:
def expect(p):
    ans = sums[p-1]/p
    return ans

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

sums = [1]*max(p)
for i in range(1, max(p)):
    sums[i] = sums[i-1] + i+1

exP = []
for idp in p:
    ex = expect(idp)
    exP.append(ex)

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

expect = [(1/num[i])*num[i]*(num[i]+1)/2 for i in range(n)]
sum_e = [sum(expect[i:i+k]) for i in range(n-k+1)]

print(max(sum_e))

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

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

i = np.argmax(ppp)

tmp = p[i:i+K]
m=0
for t in tmp:
  m+= t*(t+1)/2/t
print(m)

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):
    b.append(sum(a[i:i+k]))
    
print((k+max(b))/2)

Submission status: Time Limit Exceeded

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

frst_idx = 0
MAX = 0
for i in range(N - K + 1):
    MAX = max(MAX, (sum(p[i : i + K]) + K) * 0.5)
print(MAX)

Submission status: Time Limit Exceeded

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

max = []
for i in range(N-K+1):
    #print(i)
    target = P[i:i+K]
    #print(target)
    if sum(max) < sum(target):
        max = target

#print(max)
ans = []
for i in max:
    ans.append((i*(1+i)/2)/i)

print(sum(ans))

Submission status: Time Limit Exceeded

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

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

ls = sorted(ls,key=lambda x:x[k])

ans = 0
for i in range(k):
    for j in range(ls[-1][i]):
        ans += (1/ls[-1][i]*(j+1))
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(a):
    sum = ((1+a)*a/2)/a
    return sum

n, k = map(int, input().split())
p = [int(_) for _ in input().split()]

ans = 0
ans_index = 0
for i in range(0, n-k+1):
    val = 0
    for j in range(k):
        val += p[i+j]
    if val > ans:
        ans = val
        ans_index = i

sum = 0
for i in range(ans_index, ans_index+k):
    sum += kitaichi(p[i])

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
new_p = []
temp = 0
temp_max = 0
    
for i in range(len(p) - k + 1):
    if temp_max < sum(p[i:i + k]):
        temp_max = sum(p[i:i + k])
        temp = i

for i in p[temp:temp + k]:
    new_p.append(((i * (i + 1)) / 2) / i)

print(sum(new_p))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
#最大のリストを選定
for i in range(0,n-k+1):
    ck = sum(p[i:i+k])
    if ck > max:
        max = ck

#計算
print((max+k)/2.0)

Submission status: Time Limit Exceeded

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

max_scope_list = []
for p_i in range(len(p_list)):

    now_scope_list = []
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        now_scope_list.append(p_list[p_i + i])

    if sum(max_scope_list) < sum(now_scope_list):
        max_scope_list = now_scope_list

sum_expected_value = 0
for scope in max_scope_list:
    expected_value = 0
    for num in range(1, scope+1):
        expected_value += num*1/scope
    sum_expected_value += expected_value
print(sum_expected_value)

Submission status: Time Limit Exceeded

Solution code:
#import time 

#t1 = time.time()
N, K = map(int, input().split())
#P_list = [i for i in map(int, input().split())]

def func(a):
	a_list = [i/a for i in range(1, a+1)]
	return sum(a_list)

ALL_dice = [i for i in range(1, 1001)]
ALL_exp = list(map(func, ALL_dice))



#P_exp = list(map(func, P_list))

P_exp = [ALL_exp[i-1] for i in map(int, input().split())]

A_list = []
sum_K = 0
for i in range(N-K+1):
	for j in range(K):
		sum_K += P_exp[i+j]

	A_list.append(sum_K)
	sum_K = 0

print(max(A_list))
#print(A_list)
#t2 = time.time()
#print(t2-t1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

max_d = 0

for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += (1 + a[i + j])/2
    if d > max_d:
        max_d = d


print(max_d)

Submission status: Time Limit Exceeded

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

p = list(map(int,input().split()))
max = 0
for i in range(N-K+1):
    tmp = 0
    tmp += ((p[i]*(1+p[i]))/2)/p[i]
    for j in range(K-1):
        tmp += ((p[i+j+1]*(1+p[i+j+1]))/2)/p[i+j+1]
    if max < tmp:
        max = tmp
        
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import queue
import copy
import math
from collections import deque
import bisect

# 2つの入力を空白で分割し、数値化
n, k = map(int, input().split())

# 空白区切りの数値をリスト化
pn = list(map(int, input().split()))

expects = []

max_e = 0
start = -1

for i in range(0, n - k + 1):
    tmp = sum(pn[i:i+k])
    if tmp > max_e:
        start = i
        max_e = tmp

candidate = pn[start:start + k]

for p in candidate:
    e = (((1 + p) * p) // 2) / p
    expects.append(e)

print(sum(expects))

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np
import sys
input=sys.stdin.readline

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

#p=np.array(list(map(int,input().split())))
func=lambda x: ((int(x)+1.)/2.)
p=list(map(func,input().split()))

#p=(p+1.)/2.
max_p=0

for i in range(n-k+1):
    #s=np.sum(p[i:i+k])
    s=sum(p[i:i+k])
    if  max_p < s:
        max_p=s

print(max_p)

Submission status: Time Limit Exceeded

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

n, k = int(n), int(k)

ans = 0

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


print(ans / 2)

Submission status: Time Limit Exceeded

Solution code:
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    x = [0]
    _sum = 0
    for i in range(1,max(p)+1):
        _sum += i
        x.append(_sum)
    v = []
    for i in range(n):
        v.append(x[p[i]]/p[i])
    ans = 0
    for i in range(n-k+1):
        res = 0
        for j in range(k):
            res += v[i+j]
        ans = max(ans,res)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

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

from collections import deque
q = deque()

for i in range(n-k+1):
    if i==0:
        for j in range(k):
            mu = (p[j]+1)/2
            q.append(mu)
            M = sum(q)
    else:
        q.popleft()
        mu = (p[i+k-1]+1)/2
        q.append(mu)
        m = sum(q)
        M = max(m,M)

print(M)

Submission status: Time Limit Exceeded

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


def ex(list):
    ans = 0
    for i in list:
        ans += (i+1)/2
    return(float(ans))


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

print('{:.12f}'.format(ex(maxlist)))

Submission status: Time Limit Exceeded

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

mev = 0
idx = 0

for i in range(N-K+1):
    ev = sum(p[i:i+K])

    if ev > mev:
        idx = i
        mev = ev

print(sum(map(lambda x: (x+1.0)/2.0, p[idx:idx+K])))

Submission status: Time Limit Exceeded

Solution code:
import numpy
N, K = map(int, input().split())
p = numpy.array(list(map(int, input().split())))
max = 0
for i in range(N-K+1):
    temp = numpy.sum(p[i:i+K])
    if max < temp:
        max = temp
        maxno = i

exsum = 0

for i in range(K):
    dice = list(range(1, p[i+maxno]+1))
    ex = 0
    p2 = 1/len(dice)

    for x in dice:
        px = p2*x
        ex += px
    exsum += ex
print(exsum)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p_ = [sum(p[i:i+k]) for i in range(len(p)-k+1)]
p_i = p_.index(max(p_))
l = p[p_i:p_i+k]
ans = sum([j*1/i for i in l for j in range(1,i+1)])
print('{:.12f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
n_dice, n_choice = map(int, input().split())
dice_EV_list = tuple(map(lambda x:(x*(x+1))/(2*x) , map(int, input().split())))
sumofEV_list = [sum(dice_EV_list[i:i+n_choice]) for i in range(n_dice - n_choice + 1)]
print(max(sumofEV_list))

Submission status: Time Limit Exceeded

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

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

def summ(i):
    s = 0
    for j in range(1,i+1):
        s += j
    return s

ss = 0
for i in s:
    ss += summ(i)/i

print(ss)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
listp = tuple(map(int, input().split()))
listans1 = []
for n in range(N-K+1):
    b = sum(listp[n:n+K])
    listans1.append(b)
#print(listans1) 
print((max(listans1)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
past = -2000
resNum = -2000
for el in range(N - K + 1):
    data = copy.copy(p)
    tar = sum(data[el: el + K])
    if past < tar:
        past = tar
        resNum = el
print(past)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().split(" ")]
dice_nums = [(int(i)+1)/2 for i in input().split(" ")]
dice_maxs = [sum(dice_nums[i:i+K]) for i in range(N-K+1)]
print(max(dice_maxs))

Submission status: Time Limit Exceeded

Solution code:

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

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

print((max_i+k)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(k,n+1):
  p = l[i-k:i]
  s = sum([p[j]*(p[j]+1)/2/p[j] for j in range(k)])
  
  if ans < s:
    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()))
E=sum(p[0:K])
for i in range(N-K+1):
    if E<=sum(p[i:i+K]):
        E=sum(p[i:i+K])
print((E+K)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
new_lis = []
for i,l in enumerate(lis):
    if i+k <= len(lis):
        new_lis.append((sum(lis[i:i+k])+k)/2)
#print(new_lis)
print(max(new_lis))

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split(" ")]
lst = [int(n) for n in input().split(" ")]

sum_max = 0

for i in range(0,N-K+1):
    temp = 0
    for j in range(i,i+K):
        temp += (lst[j]+1)/2
    if temp > sum_max:
        sum_max = temp
print(sum_max)

Submission status: Time Limit Exceeded

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

for i in range(N):
  sum_pk = 0
  for j in range(K):
    if i > N - K:
      continue
    else:
      sum_pk = sum_pk + P[i + j]
  max_sum = max([sum_pk,max_sum])
print(K / 2 + max_sum / 2)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(float(ans))

Submission status: Time Limit Exceeded

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

def expected_value(list):
  exp_list = []
  for i in range(len(list)):
    exp = (list[i]+1)/2
    exp_list.append(exp)
  return exp_list

ans = 0
ans_list = []
for i in range(N-K+1):
  exp = sum(p[i:i+K])
  if exp >= ans:
    ans = exp
    ans_list = p[i:i+K]
    
print(sum(expected_value(ans_list)))

Submission status: Time Limit Exceeded

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

m = 0
t = 0
ans = 0

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


ans = sum(li[t:t+K]) + K
ans=ans - li[t:t+K].count(1)

ans=ans / 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = 0
for n in range(N-K+1):
    tmp = 0
    for i in range(K):
        V[n+i] = (0.5*Pn[n+i]*(Pn[n+i]+1))/Pn[n+i]
        tmp += V[n+i]
    ans = max(ans, tmp)

print(ans)

Submission status: Time Limit Exceeded

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