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())
P = list(map(int, input().split()))

m = 0
p = []
for i in range(n - k + 1):
    tmp = P[i:i+k]
    if m < sum(tmp):
        m = sum(tmp)
        p = tmp

s = 0
for i in p:
    s += (1 + i) / 2

print(s)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict

IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())

n,m=IA()
a=list(IA())
ans=float(0)
for i in  range(0,n):
    if i+m>n:break
    sum1=float(0)
    for j in range(0,m):
        
        sum1+=(a[i+j]+1)/2
    #print(sum1)
    ans=max(ans,sum1)
print("%.12lf"%ans)
N=int(100005)
a=[int(0) for i in range(N)]

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


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

    sums = []
    for n in range(N):
        if n > N-K:
            break
        sums.append(sum(P[n:n + K]))
    idx = sums.index(max(sums))
    E = []
    for i in range(idx, idx+K):
        e = sum(range(1, P[i]+1)) / P[i]
        E.append(e)
    print(sum(E))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, k  = MAP()
p = LIST()

def kitai(a):
    tmp = 0
    # for a in A:
    tmp = 1/a * (1/2 * a * (a+1))
    return tmp
    

ans = 0
# A = []
c = 0
B = []
for i in range(n-k+1):
    A = p[i:i+k]
    if c != max(c, sum(A)):
        c = sum(A)
        C = deepcopy(A)
    B.append(A)

# print(C)

for a in C:
    # print(a)
    ans += kitai(a)
# ans = max(ans, k)
print(ans)

# for A in B:
#     k = 0
#     for a in A:
#         # print(a)
#         k += kitai(a)
#     ans = max(ans, k)
# print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
m = []
for i in range(n-k+1):
    l.append(p[i:i+k])
    m.append(sum(p[i:i+k]))
Max_index = m.index(max(m))

ll = l[Max_index]
ans = 0
for i in ll:
    Sum = 0
    for j in range(1,i+1):
        Sum += j
    ans += Sum/i   
print(ans)

Submission status: Time Limit Exceeded

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

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

print(max_ev)

Submission status: Time Limit Exceeded

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

ps_k = [sum(ps[i:i+k]) for i in range(n)]

start = ps_k.index(max(ps_k))

print(sum([sum(range(i+1))/i for i in ps[start:start+k]]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


len_arr, width = map(int, input().split())
dices = np.array(list(map(int, input().split())))

ps = np.array([np.sum(dices[i:i+width]) for i in range(0, len_arr - width + 1)])
idx = ps.argmax()
# target = dices[idx:idx+width]

expected = (dices[idx:idx+width].sum() + width) * 0.5
print(expected)

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# abc 154
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

def cal_expected(p):
    expected = 0
    for i in range(1, p+1):
        expected += i / p
    return expected

# 対象特定
dices = []
dices_sum = 0
for start in range(0, N-K+1):
    tmp_dices = P[start:start+K]
    tmp_sum = sum(tmp_dices)
    if tmp_sum > dices_sum:
        dices = tmp_dices
        dices_sum = tmp_sum

# 期待値計算
answer = sum(map(cal_expected, dices))
print(answer)

Submission status: Time Limit Exceeded

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

    m = 0
    a = 0
    for i in range(n-k+1):
        wa = 0
        for j in range(k):
            wa += p[i+j]
        if m < wa:
            a = i
            m = wa

    ans = 0
    for i in range(a, a+k):
        x = p[i]
        ans += (1/2*x*(x+1))/x

    print(ans)


main()

Submission status: Time Limit Exceeded

Solution code:
n, k, *p = map(int, open(0).read().split())

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

print(max_e)

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
exp = []
for p in P:
    exp.append(sum(range(1,p+1))/p)
high = 0
for i in range(N-K+1):
    tmp = 0
    for e in exp[i:i+K]:
        tmp += e
    if tmp > high:
        high = tmp
print(high)

Submission status: Time Limit Exceeded

Solution code:
n, k = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
p_sum = [sum(p[i:i+k]) for i in range(len(p)-k+1)]
idx = p_sum.index(max(p_sum))
print(sum([(p_i*(p_i+1))/2 / p_i for p_i in p[idx:idx+k]]))

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 = [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
res = p[resNum: resNum + K]
result = 0
for el in res:
    result += (1/2+el/2)
print(result)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# = int(input())
n,k = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]
psk = []
def kitaichi(m):
    ret = 0
    for j in range(m,m+k):
        ret += (ps[j]+1)/2
    return ret
for i in range(n-k+1):
    psk.append(kitaichi(i))
psk = sorted(psk)
print(psk[-1])

Submission status: Time Limit Exceeded

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

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

max_ind = B.index(max(B))

ep = 0
for i in range(K):
    ep += (p[max_ind+i]*(p[max_ind+i]+1))/(2*p[max_ind+i])

print(ep)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

res = 0

p = list(map(lambda x:(x+1)/2, p))
for i in range(N-K+1):
    kk = 0
    for j in range(K):
        kk += p[i+j]
    res = max(res, kk)

print(res)

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)
p1 = sum((p[0:0+k] + 1)/2)

ansum = np.array([p1])
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum = np.append(ansum, p1)

print(max(ansum))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(maxsum)

Submission status: Time Limit Exceeded

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

ans_i = 0
ans_max = 0
ans = 0

for i in range(0, n-k+1):
    x = sum(p[i:i+k])
    if x > ans_max:
        ans_max = x
        ans_i = i
        
for j in range(ans_i, ans_i+k):
    ans += (p[j]+1)/2
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def hoge(ls):
    e_value = []
    for l in ls:
        tmp = 0
        for i in range(1, l+1):
            tmp += i
        tmp = tmp / l
        e_value.append(tmp)
    return sum(e_value)


ans = []
for i in range(N-K+1):
    tmp = nums[i:i + K]
    ans.append(hoge(tmp))

print(max(ans))

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]
    ans = max(ans, ex(p))

print('{:.12f}'.format(ans))

Submission status: Time Limit Exceeded

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

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

    ans.append(temp)

ans.sort(reverse=True)
print(ans[0])

Submission status: Time Limit Exceeded

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

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

print(max_num)

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):
    temp = 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 = [int(p) for p in input().split()]
su = 0
for i in range((n-k+2)//2):
    s = sum(P[i:k+i])
    p = sum(P[n-k-i+1:n-i+1])
    if s > su:
        su = s
    else:
        pass
    if p > su:
        su = p
    else:
        pass
ans = (su + k)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

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

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

res = []

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

Submission status: Time Limit Exceeded

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

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

ans = 0
for i in range(k):
    if kukan_list[i] % 2 == 0:
        x = kukan_list[i] / 2 + 0.5
    else:
        x = kukan_list[i] // 2 + 1
    ans += x
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = []
for i in range(n):
    b.append((1+a[i])/2)
    
ans = sum(b[:k])
for i in range(1,n-k+1):
    ans= max(sum(b[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()))

max_v=0

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

for i in range(max_i,max_i+K):
    ans += (1/2*p[i]*(p[i]+1))/p[i]

print(ans)

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 = (np.array(P) + 1) / 2

f = np.ones(K)

x = np.convolve(E, f, mode='valid')
print('{:.10f}'.format(x.max()))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
raw = input()
N, K = raw.split(' ')
N = int(N)
K = int(K)
str_li = input().split(' ')
num_li = list(map(int, str_li))
ans = 0
for index in range(N-K+1):
    s = (sum(num_li[index: index+K]) + K) / 2
    if s > ans:
        ans = s

print(ans)

Submission status: Time Limit Exceeded

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

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])
M=0
for i in range(N-K+1):
    x = p[i:i+K]   
    M=max(M,ex3(x))
print (M)

Submission status: Time Limit Exceeded

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

print(max([sum(A[i:i+K]) for i in range(0,N,1)]))

Submission status: Time Limit Exceeded

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

m = 0
t = 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 = 0

for i in range(t, t + K):
    if li[i] == 1:
        ans = ans + 1
    else:
        ans = ans + li[i] + 1

ans = ans / 2
print(ans)

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(p[i:K+i])
    L.sort()
num=0

for l in L[-1]:
    num=num+(l+1)/2
print(num)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

ans = 0
l = list()
for i in range(N):
    l.append((p[i] * (p[i] + 1)) / 2 / p[i])

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

print(ans)

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
e = 0
for i in range(j, j + k):
    e += (1 + p[i]) / 2
print(e)

Submission status: Time Limit Exceeded

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

max_E = 0
for i in range(N-K+1):
    tmp_E = (sum(P[i: i+K]) + K) / 2
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

Submission status: Time Limit Exceeded

Solution code:

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

s_max = 0
for j in range(N - K + 1):
    s = 0
    for i in range(K):
        s += (p[i+j] + 1) / 2

    if s_max < s:
        s_max = s

print(s_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate

def helpme(ary):
    v = 0
    for i in ary:
        v += kitaichi(i)
    return v

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

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


    ans = helpme(P[:K])
    tmp = ans
    for i in range(1, N-K+1):
        prev = kitaichi(P[i-1])
        suc = kitaichi(P[i+K-1])
        tmp = tmp-prev+suc
        ans = max(ans, tmp)

    print(ans)



main()

Submission status: Time Limit Exceeded

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    
    
    ans_start = 0
    tmp = sum(p[:K])
    ms = tmp

    for i in range(K, N):
        tmp = tmp + p[i] - p[i - K]
        if tmp > ms:
            ans_start = i - (K - 1)
            ms = tmp
    
    target = p[ans_start:ans_start + K]
    
    
    ans = 0
    for t in target:
        l = [x for x in range(1, t + 1)]
        ans += sum(l) / t

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in range(len(l)):
  ans=sum(l[i:i+k])
  maxans=max(ans,maxans)
print(maxans)

Submission status: Time Limit Exceeded

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

tmp = 0
tmp_i = 0
for i in range(n-k+1):
    a = sum([p[x] for x in range(i, i+k)])
    if a > tmp:
        tmp = a
        tmp_i = i

ans = 0
for x in range(k):
    num = p[tmp_i+x]
    ans += sum(range(num+1)) / num

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
E = [0] * N
S = [0] * (N - K + 1)

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

for i in range(N-K+1):
  S[i] = sum(E[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()))
Kitai=[0]
for k in range(0,N-K+1):
  On=0
  for l in range(0,K):
    On+=(1+P[k+l])/2
  Kitai.append(On)

print(max(Kitai))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

mev = 0

for i in range(N-K+1):

    ev = sum(map(lambda x: (x+1.0)/2.0, p[i:i+K]))

    if ev > mev:
        mev = ev

print(mev)

Submission status: Time Limit Exceeded

Solution code:
[n, k]= map(int, input().rstrip().split(" "))
ps = list(map(int, input().rstrip().split(" ")))

history = {}

top3 = []

result = 0

def calc_expect_sum(targets):
    return sum( (p+1) * 0.5 for p in targets)


for i in range(n-k+1):
    targets = ps[i:i+k]
    new = calc_expect_sum(targets)
    if new > result:
        result = new

print(result)

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 = []
    ans = 0
    for i in range(n):
        v.append(x[p[i]]/p[i])
        if i >= k - 1:
            ans = max(ans,sum(v[i-k+1:i+1]))
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, input().split())
l = list(map(int, input().split()))
max = 0
e = 0
temp = 0
pr = []

for i in range(a-b+1):
  temp = sum(l[i:i+b])
  if temp >= max:
    max = temp
    pr = l[i:i+b]

for j in pr:
  e += (j+1) / 2 
  
print(e)

Submission status: Time Limit Exceeded

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

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

max_e=0
for i in range(N-(K-1)):
  v=p[i:K+i]
  #print(v)
  e=list(map(calc, v))
  #print(e)
  e=sum(e)

  if max_e<e:
    max_e=e

print(max_e)

Submission status: Time Limit Exceeded

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

DP=[0]*1001
for i in P:
    if DP[i]==0:
        DP[i]=(i*(i+1)//2)/i
    K.append(DP[i])

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

Submission status: Time Limit Exceeded

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

print(ans_max)

Submission status: Time Limit Exceeded

Solution code:
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
sum = 0
sum_t = 0
for i in range(N-K+1):
    sum_t = 0
    for j in range(i, i+K):
        sum_t += ((1+p[j])*p[j])/(2*p[j])

    if sum_t >= sum:
        sum = sum_t
    else:
        pass

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
P = LIST()

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

ma = 0
for i in range(N - K + 1):
	ma2 = 0
	for j in range(K):
		ma2 += acc[i+j]
	if ma < ma2:
		ma = ma2

print(ma)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def e_val(p_i):
  return (p_i+1)/2

n, k, *p = map(int, open(0).read().split())

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

print(max_e)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
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)

P_exp = list(map(func, P_list))

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)

Submission status: Time Limit Exceeded

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

A=[]
answer=0
B=[]

for i in range(N):
    sum=0
    for j in range(1,p[i]+1):
        sum+=j
    A.append(sum/p[i])

for k in range(N-K+1):
    count=0
    for l in range(K):
        count+=A[k+l]
    B.append(count)

print(max(B))

Submission status: Time Limit Exceeded

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


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

    m = 0
    for i in range(N):
        left = i
        right = min(i+K, N)

        s = sum(ps[left:right])
        m = max(m, s)

    print(m)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
result = 0
for i in range(N-K+1):
    if result <= sum(p[i:i+K]):
        result = sum(p[i:i+K])
    else:
        None
print((result+K)/2)

Submission status: Time Limit Exceeded

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

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

print(max(temp))

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    max_sum = 0
    for i in range(n - k + 1):
        # print(i, p, k)
        r = sum(p[i:i + k])
        # print(r)
        if r > max_sum:
            max_sum = r

    print((max_sum / 2) + (k * 0.5))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
max_l = 0
max_i = 0
ans = 0
if k == 1:
    a = max(l)
    print(a * (a + 1) / 2 / a)
else:
    for i in range(n - k + 1):
        hikaku = 0
        for j in range(k):
            hikaku += l[i+j]
        if max_l < hikaku:
            max_i = i
            max_l = hikaku
    for i in range(k):
        a = l[max_i + i]
        ans += a * (a + 1) / 2 / a
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def kitaichi(a):
    sum = 0
    for i in range(a):
        sum += i+1
    return sum / a

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:
hoge = input().split()

N = int(hoge[0])
K = int(hoge[1])
p_list = []

hoge = input().split()

for i in range(N):
  p_list.append(int(hoge[i]))
  
big = 0
for i in range(N-K+1):
  _sum = sum(p_list[i:i+K])
  if _sum > big:
    big = _sum
    
ans = (float(big) / 2) + 0.5 * float(K) 
print(ans)

Submission status: Time Limit Exceeded

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

l = 0
r = k

result = 0.0
while r != len(p)+1:
  this_res = 0.0
  for pi in p[l:r]:
    this_res += pi / 2 + 1/2
  result = max(result, this_res)
  l += 1
  r += 1

print(result)

Submission status: Time Limit Exceeded

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

for j in range(N):
  L[j]=(1+L[j])*L[j]/2/L[j]
  
def sumlist(a):
  return sum(L[0:a])

for i in range(N-K+1):
  sumL.append(sumlist(i+K)-sumlist(i))
  
print(max(sumL))

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

Submission status: Time Limit Exceeded

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

tem=0
ans=0

for i in range(n-k+1):
    tem=0
    if i>1 and p[i-1]>p[i+k-1]:
        continue
    for j in range(k):
        tem=tem+(p[i+j]/2)+1/2
    ans=max(ans,tem)

print(ans)

Submission status: Time Limit Exceeded

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

def calc_exp(n):
    exp=1+(n-1)*0.5
    return exp

for i,val in enumerate(p):
    p[i]=calc_exp(val)

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