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:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
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 functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    P = LIST()

    ans = 0
    for i in range(N-K+1):
        tmp = 0
        for j in range(K):
            tmp += P[i+j] * 0.5 + 0.5
        ans = tmp if tmp > ans else ans

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
n, k = map(int, input().split())
p =list(map(int,input().split()))
pp =[]
for i in range(len(p) - k + 1):
  tmp = 0
  for j in range(k):
    tmp += p[i+j]
  pp.append(tmp)
mn = max(pp)
ans = (mn + k) / 2
print(ans)

Submission status: Time Limit Exceeded

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

#連続するK個の要素の和で一番大きいもの
start = -1
maximum = -1
for i in range(len(p) - k + 1):
  temp = sum(p[i:i + k])
  if temp > maximum:
    maximum = temp
    start = i

#期待値の算出
exp = 0
for i in range(start, start + k):
  temp = 1 / 2 * p[i] * (p[i] + 1)
  exp += temp / p[i]

print(exp)

Submission status: Time Limit Exceeded

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

tmp_max = 0

def kitaichi(dice):
    dice = range(1,dice+1)#サイコロの事象
    ex = 0#期待値を演算するための変数
    p = 1/len(dice)#サイコロの確率

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

    #print("EX = ",ex)
    return ex

list_kitaichi = []

for p in (P):
    list_kitaichi.append(kitaichi(p))
#print(list_kitaichi)

tmp_max = 0
tmp_pair = []
for i in range(len(list_kitaichi)-K+1):
    #print(list_kitaichi[i:i+K], sum(list_kitaichi[i:i+K]))
    if sum(list_kitaichi[i:i+K]) > tmp_max:
        # 最大値更新
        tmp_max=sum(list_kitaichi[i:i+K])
        # 最大値のペアを変更
        tmp_pair=list_kitaichi[i:i+K]
        
#print("tmp_max", tmp_max)
#print("tmp_pair",tmp_pair)


print(tmp_max)

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 = P[i:i+k]
    if m < sum(tmp):
        m = sum(tmp)

print((m + k) / 2)

Submission status: Time Limit Exceeded

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

dic = {}

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from pprint import pprint

def solve(n, k, p):
    E = {}
    p_map = {}
    for i, p_i in enumerate(p):
        E[p_i] = (1.0 + p_i)/2
        p_map[i] = p_i
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        ans = max(ans, sum([E[p_map[i+j]] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def estim(n): 
    return float(0.5*(n+1))

final_ans=0
for i in range(N-K+1):
    ans=0
    for j in  range(i,i+K):
        ans+=(estim(p[j]))
        if ans>=final_ans:
            final_ans=ans

print(final_ans)

Submission status: Time Limit Exceeded

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

m = 0
import numpy as np
p = np.array(p)
for i in range(k):
  m += np.hstack([p[i:], np.zeros(i)])  

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

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):
  if sum(p[ind:ind+k]) >= max_val:
    max_val = sum(p[ind:ind+k])
max_val = float(max_val)
k = float(k)
print(max_val/2+k/2)

Submission status: Time Limit Exceeded

Solution code:
numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])
dices_input = input().split(" ")
dices = []
for i in dices_input:
    dices.append(int(i))

expected = []
for j in range(n-k+1):
    ex = 0
    for x in range(k):
        ex += dices[j + x] + 1
    expected.append(ex * 0.5)
print(max(expected))

Submission status: Time Limit Exceeded

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

m = 0
ii = 0
for i in range(k, n+1):
    mi = sum(pn[i-k:i])
    if m < mi:
        m = mi
        ii = i
print((m + k)/2)

Submission status: Time Limit Exceeded

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

s_max = 0

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

s_max = (s_max + k) / 2

print(s_max)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
for i in range(n-k+1):
    ans = 0
    for j in range(i,i+k):
        ans += p[j]
    if ans > val:
        val = ans
        atai = i

#print(atai)
ans = 0
for i in range(k):
    kitai = 0
    for j in range(1,p[atai]+1):
        kitai += j
    ans += kitai / p[atai]
    atai += 1
    #print(atai)
    #print(kitai)
print(ans)

Submission status: Time Limit Exceeded

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

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):
  tmp=0
  for j in range(k):
    tmp+=(li[i+j]+1)/2
  if max <= tmp:
    max=tmp
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())))

best=0
bestP=np.array([0]*K)
for i in range(N-K+1):
  if P[i:i+K].sum()>best:
    best=P[i:i+K].sum()
    bestP=P[i:i+K]
    

print(((bestP+1)/2).sum())

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m = [sum(P[i:i+K]) for i in range(N-K+1)]
m_index = m.index(max(m))

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]   
  if candidate > maxval:
    maxval = candidate
  prevval = candidate
  
print(maxval)

Submission status: Time Limit Exceeded

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

mind = -1
mmax = -1

for i in range(N-K+1):
    ksum = sum(PP[i:i+(K)])
    if ksum > mmax:
        mind = i
        mmax = ksum
        
        
maxrange = PP[mind:(mind+K)]

esum = 0
for m in maxrange:
    esum += (m+1)/2
    
print(esum)

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

Submission status: Time Limit Exceeded

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

def S(data,i,x):
    m=0
    for j in range(i,i+x):
        m=m+data[j]
    return m

y=0
for i in range(0,N-K+1):
    if S(p,y,K)<S(p,i,K):
        y=i

def E(z):
    s=0
    for w in range(1,z+1):
        s=s+w
    return s/z

q=0
for l in range(y,y+K):
    q=q+E(p[l])

print(q)

Submission status: Time Limit Exceeded

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

t = [0]*n
n = n-(k-1)
for i in range(n):
    for j in range(i,i+k):
        t[i] += p[j]
T = t.index(max(t))
ans = 0
for i in range(k):
    ans += (p[T+i]+1)/2
print(ans)

Submission status: Time Limit Exceeded

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

prev = 0
ind = 0
for i in range(n-k+1):
    nex = 0
    for j in range(i,i+k):
        nex += p[j]

    if prev < nex:
        prev = nex
        ind = i

total = 0
for i in range(ind,ind+k):
    total += (sum(tuple(range(1, p[i]+1))))/p[i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
def quick_sort(list):
    stand=list[0]
    over=[]
    same=[]
    under=[]
    for i in list:
        if(i>stand):
            over.append(i)
        elif(i<stand):
            under.append(i)
        else:
            same.append(i)
    if(len(over)>1):
        over=quick_sort(over)
    else:
        pass
    if(len(under)>1):
        under=quick_sort(under)
    else:
        pass

    return over+same+under

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, k = map(int, input().split())
a_np = np.array(list(map(int, input().split())))

ans = []

for i in range(n-k+1):
    ans.append((a_np[i:i+k].sum()+k)/2)

print(max(ans))

Submission status: Time Limit Exceeded

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

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

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

print((k+a)/2)

Submission status: Time Limit Exceeded

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

print(exp)

Submission status: Time Limit Exceeded

Solution code:
def calc_E(prob):

    E = sum([i for i in range(1, prob+1)]) / prob
    return E

def main(N, K, list_p):
    
    max_E = 0

    for i in range(N-K+1):
        tmpE = 0
        for j in range(K):  tmpE += calc_E(list_p[i+j])
        if tmpE >= max_E :  max_E = tmpE
    
    return max_E
        


if __name__ == "__main__":

    [N, K] = list(map(int, input().split(' ')))
    list_p = list(map(int, input().split(' ')))

    answer = main(N, K, list_p)
    print(answer)

Submission status: Time Limit Exceeded

Solution code:
def calc_ex(x):
  p = 1 / x
  ex = 0
  for i in range(x + 1):
    px = p * i
    ex += px

  return ex

ans = 0

n, k = map(int, input().split())
p = [int(i) for i in input().split()]
p_ex = list(map(calc_ex, p))

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, K = mulinputs()
# ps = list(mulinputs())
memo = dict()
def kitaiti(s):
    if s in memo.keys():
        return memo[s]
    n = int(s)
    k = sum(range(int(n)+1))/int(n)
    memo[s] = k
    return k
ps = list(map(kitaiti, input().split()))

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


# 出力
print(ans)

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 = []
ll = []

for i in range(a-b+1):
  pr.append(sum(l[i:i+b]))

for j in range(len(pr)):
  if max < pr[j]:
    temp = j
    max = pr[j]

ll = [l[i] for i in range(temp, temp+b)]

for x in ll:
  e += (x+1)/2

print(e)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split(" ")[0:2])
p = list(map(int,input().split(" ")))

ret = -1
for x in range(0,N-K+1):
    ret1 = (sum(p[x:x+K])+K)/2
    ret = ret if ret1 < ret else ret1

print(ret)

Submission status: Time Limit Exceeded

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

kitai = [None]*(1000+1)
for i in range(1, 1001):
    kitai[i] = (0.5*i*(i+1))/i
ans = 0
ans_list=[]
for i in range(0, N-K+1):
    temp = P[i:i+K]
    temp2 = sum(temp)
    if ans < temp2:
        ans = temp2
        ans_list = temp

ans = 0
for al in ans_list:
    ans += kitai[al]
print(ans)

Submission status: Time Limit Exceeded

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

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

print(max(l_kitaichi))

# ans_i = new_list.index()
#
# print(new_list.)
#
# print(ans_i)
#
# print(sum([(1 + v) / 2 for v in new_list]))
#
# print(new_list)

# max_kitaichi = 0
# max_left_n = 0
# for left_n in range(N - K + 1):
#
#     new_kitaichi = sum([(1 + pv) / 2 for pv in p[left_n:left_n + K]])
#
#     if new_kitaichi > max_kitaichi:
#         max_kitaichi = new_kitaichi
#
# print(max_kitaichi)

Submission status: Time Limit Exceeded

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

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(ans_list)+K)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
s=[0]
marking=0
for i in range(n):
    se=l[i:i+k]
    if sum(se)>=sum(s):
        s=se

ans=(sum(s)+k)/2
print(ans)

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 = kukan / 2 + 0.5 * k
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
arr = np.array([int(i) for i in input().split()])
max = 0
max_p = 0

for i in range(0, n-k+1):
  t = sum(arr[i:i+k])
  if max < t:
    max = t
    max_p = sum([_*(_+1)/(_*2.0) for _ in arr[i:i+k]])

print(max_p)

Submission status: Time Limit Exceeded

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

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

#p2 = [(i+1)/2 for i in p]
#for i,px in enumerate(p):
#  p2[i] = (px+1)/2

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

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 = numpy.arange(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:
import sys, re
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,copy
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 LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, k = MAP()
    p = LIST()

    ans = []

    dic = defaultdict(int)

    for i in range(n-k+1):
        q = p[i:i+k]
        dic[i] = sum(q)

    #print(dic)
    ma = max(dic.values())
    dic_ = sorted(dic.items(), key=lambda x:x[1], reverse = True)
    #print(dic_)

    for i, x in dic_:
        if x != ma:
            break

        tmp = 0
        #print('-----', p[i:i+k])
        for x in p[i:i+k]:
            tmp += sum(range(1, x+1))/x
        
        ans.append(tmp)

    print(max(ans))

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

max_s = 0
for i in range(N):
  if i+K < N and P[i] < P[i+K]:
    continue
  elif i+K > N:
    continue
  sum_K = sum(P[0+i:K+i])
  if max_s < sum_K:
    max_s = sum_K
print((max_s+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):
    x = 0
    for j in range(k):
        pj = p[i + j]
        x += (1 + pj) / 2
    ans = max(ans, x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K,*P = map(int,open(0).read().split())
m = [0]*N
E = [((n+1))/2 for n in range(1,1001)]
for i in range(0,N-K+1):
  tmp_sum = 0
  for j in range(K):
    tmp_sum+=E[P[i+j]-1]
  m[i]=tmp_sum
print(max(m))

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

    e = list(map(get_expect, P))

    print(max([
        sum(
            e[i:i + K]
        )
        for i in range(N - K + 1)
    ]))


if __name__ == "__main__":
    main()

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 call(tmp):
  m=0
  for t in tmp:
    m += 0.5*(t+1)
  return m

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

i = np.argmax(ppp)
print(ppp[i])

Submission status: Time Limit Exceeded

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

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

print((np.max(np.convolve(p,np.ones(K),'valid'))+K)/2)

Submission status: Time Limit Exceeded

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

tmp = []
ans = 0
for i in range(n):
    tmp.append(pl[i]*(pl[i]+1)/2/pl[i])
    if i >= k-1:
        if sum(tmp[i-k+1:i+1]) > ans:
            ans = sum(tmp[i-k+1:i+1])
print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

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

ev = 0

for i in range(idx, idx+K):
    ev += ((p[i] + 1.0) / 2.0)

print(ev)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

def main2():
    ans = 0
    for i in range(n-k+1):
        ans = max(ans, ((np_p[i:i+k]+1)/2).sum())
    print(ans)

main2()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
pis = list(map(int, input().split()))
sum_max = 0
pikmax = []
for i in range(n-k+1):
  pik = pis[i:i+k]
  sumk = sum(pik)
  if sumk > sum_max:
    sum_max = sumk
    pikmax.append(pik)
expect = 0
expect += sum_max/2 + k / 2
print(expect)

Submission status: Time Limit Exceeded

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

pos = 0
saidai = 0
for i in range(N-K+1):
  temp = sum(p[i:i+K])
  if saidai < temp:
    saidai = temp
    pos = i
    
kitaichi = 0
for i in range(K):
  temp = 0
  for j in range(p[pos+i] + 1):
    temp = temp + j
  kitaichi = kitaichi + float(temp/p[pos+i])
  
print('{:.12f}'.format(kitaichi))

Submission status: Time Limit Exceeded

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

maxs = [0]
# print(ps)
for i in range(n-k + 1):

    vs = ps[i:i+k]
    # print(i, vs)
    if sum(vs) > sum(maxs):
        maxs = vs

result = 0
for m in maxs:
    result += (m + 1)/2
print(result)

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
  
ans = []
for i in range(N - (K - 1)):
  a = []
  for j in range(K):
    a.append(p[i+j])
  if sum(a) > sum(ans):
    ans = a

A = 0
for x in range(K):
  A += P(ans[x])

print(A)

Submission status: Time Limit Exceeded

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

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

ans = (maxlist+K)/2
print('{:.12f}'.format(ans))

Submission status: Time Limit Exceeded

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

A=[]
answer=0
base=0
B=[]

for i in range(K):
    sum=0
    for j in range(1,p[i]+1):
        sum+=j
    base+=sum/p[i]
    B.append(sum/p[i])
A.append(base)
for j in range(K,N):
    sum=0
    for k in range(1,p[j]+1):
        sum+=k
    B.append(sum/p[j])
    base+=sum/p[j]
    base-=B[j-K]
    A.append(base)
print(max(A))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li_p = list(map(int, input().split()))
def kitaichi(a):
  b = 0
  for i in range(1, a+1):
    b += i
  return b/a
li_s = []
for x in li_p:
  li_s.append(kitaichi(x))
ans = []
d = 0
for i in range(k):
  d += li_s[i]
  ans.append(d)
for j in range(k, n):
  d += li_s[j]
  d -= li_s[j-k]
  ans.append(d)
print(max(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
m = 0
pp = []
while r != len(p)+1:
  tmp_pp = p[l:r]
  s = sum(tmp_pp)
  l += 1
  r += 1
  if s <= m:
    continue
  m = s
  pp = tmp_pp

for pi in pp:
  result += pi / 2 + 1 / 2
print(result)

Submission status: Time Limit Exceeded

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

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

    p_.append(r)

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

Submission status: Time Limit Exceeded

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

s = []
for i in range(1,max(p)+1):
    an = i*(i+1)/2/i
    s.append(an)

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

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))
a=0
for i in range(K):
  a+=(1+p[t+i])/2
print(a)

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-K+1):
  PP = P[i:K+i]
  mp = 0
  for p in PP:
      mp += sum(range(p+1))/float(p)
  if res < mp:
    res = mp

print(res)

Submission status: Time Limit Exceeded

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

for i in range(len(p_list)-k+1):
    sum_temp = sum(p_list[i:i+k])
    if i == 0:
        sum_max = sum_temp
        index = i
    elif sum_temp > sum_max:
        sum_max = sum_temp
        index = i
    
kitaichi = 0
for i in range(k):
    temp_index = index + i
    kitaichi += (1+p_list[temp_index])/2
    
print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
v_list = np.array(list(map(int, input().split())))
base_arr = v_list[0:n+1-k]
for i in range(1, k):
  base_arr = base_arr + v_list[i:n+1+i-k]
print((base_arr.max()+k)/2)

Submission status: Time Limit Exceeded

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

def expect(pi):
    sum = 0.0
    for i in range(1, pi+1):
        sum += float(i)
    return sum/float(pi)

def solve(N: int, K: int, p: "List[int]"):

    ans = 0.0
    for n in range(N-K+1):
        sum_exp = 0.0
        for e in range(K):
            sum_exp += expect(p[n+e])
        if ans < sum_exp:
            ans = sum_exp
    print(ans)

    return


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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
S = 0
for i in range(0,n-k+1):
    s = 0
    r = sum(p[i:i+k])
    if S < r:
        S = r
        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:
import numpy as np

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

    su = 0
    l_sum = []
    i = 0
    while (N-K) >= i:
        tmp_p = p[i:(i+K)]
        if sum(tmp_p) >= su:
            su = sum(tmp_p)
            l_sum = tmp_p
        i += 1

    ans = 0

    l_sum = np.array(l_sum)
    l_r = l_sum
    l_sum_1 = l_sum + 1
    l_sum = l_sum * l_sum_1
    l_sum = l_sum / 2
    l_sum = l_sum / l_r
    print(sum(l_sum))




    return 0

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

m = 0
for i in range(len(l)-(K-1)):
    if l[i] < l[i-1]:
        continue
    elif m < sum(l[i:i+K]):
        m = sum(l[i:i+K])
        t = l[i:i+K]
        
def E(n):
    return sum(range(1,n+1)) / n

l2 = list(map(E, t))

print(sum(l2))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0#man_sum
c=0#num
for i in range(n-k+1):
  s=sum(a[i:i+k])
  if b < s:
    b=s
    c=i
ans=0
#print(b,c)
for j in range(k):
  ans+=(a[c+j]+1)/2
print(ans)