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

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

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

    if s_max < s:
        s_max = s

print(s_max)

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N, K = int(NK[0]), int(NK[1])
lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(lambda x: x*(x+1)/2/x, lis_p))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Submission status: Time Limit Exceeded

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

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  for k in range(K):
    sum += p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

ans, num = 0, 0
for i in range(ai, ai+K):
  tmp = 0
  for j in range(1,p[i]+1):
    tmp += j
  ans += tmp/p[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
exp, max_exp = 0, 0
def calc_exp(p):
  # calculate expectation
  dice = list(range(1, p + 1))
  exp = float(sum(dice) / p)
  return exp
for i in range(N - K + 1):
  k, exp = 0, 0
  while k <= K - 1:
    exp += calc_exp(P[i + k])
    k += 1
  max_exp = max(max_exp, exp)
print(max_exp)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    base = [i for i in range(1, 1001)]
    l = list(itertools.accumulate(base))
    r = [l[i] / (i+1) for i in range(1000)]


    maxi = 0
    ans = 0
    for i in range(N-M+1):
        s = sum(A[i:M+i])
        if maxi < s:
            ans = 0
            maxi = s
            for a in A[i:M+i]:
                ans += r[a-1]

    return ans

print(solve())

Submission status: Time Limit Exceeded

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

for i in range(0, N-K+1):
    for j in range(i, i+K):
        temp += p[j]
    if max_val < temp:
        max_val = temp
        index = i
    temp = 0
sum_value = 0

for i in range(index, index+K):
    sum_value += (p[i]+1) / 2
print(sum_value)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

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

p1 = np.array(p)
p1 = p1 + 1
p1 = p1 / 2
p2 = copy.copy(p1)

if k == 1:
  print(np.max(p1))
else:
  for i in range(k-1):
    p1 = np.vstack([p1, np.roll(p2,i+1)])

  sums = np.sum(p1, axis= 0)
  print(np.max(sums[k-1:]))

Submission status: Time Limit Exceeded

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

ex_value = 0
max_ex_value = 0
for i in range(0,int(n-k+1)):
  ex_value = 0
  for j in range(0, k):
    x = p_list[i+j]           
    ex_value += ((x+1)*x/2)/x
  if ex_value >= max_ex_value:
    max_ex_value = ex_value
               
print(max_ex_value)

Submission status: Time Limit Exceeded

Solution code:
# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import collections

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

ma = sum(p[:K])
kukan = sum(p[:K])
idx = 0
for i in range(N - K):
  kukan = kukan - p[i] + p[i+K]
  if ma < kukan:
    ma = kukan
    idx = i+1

exp = 0
for i in range(idx, K+idx):
  exp_1 = 0
  for j in range(1, p[i]+1):
    exp_1 += j
  exp += exp_1 / p[i]

print(exp)

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 += (1+p[i])/2
    for j in range(K-1):
        tmp += (1+p[i+j+1])/2
    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(' ')))
P_set = [ P[i:i+K] for i in range(0, len(P)) if len(P[i:i+K])==K]

E = []
for dices in P_set:
    E.append(sum([sum([i for i in range(1,dice+1)]) / float(dice) for dice in dices]))
    
print('{:.12f}'.format(max(E)))

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]
  if max <= tmp:
    max=tmp
print((max+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):
    temp = p[i+maxno]
    exsum += (0.5*temp*(temp+1))/temp
print(exsum)

Submission status: Time Limit Exceeded

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

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 = 0
    for i in range(idx, idx+K):
        # e = 0.5 * (1 + P[i]) * P[i] / P[i]
        e = 0.5 * (1 + P[i])
        E += e
    print(E)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def P(n):
  return (n + 1) / 2
  
ans = []
for i in range(N - (K - 1)):
  a = p[i: i + K]
  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())
p = list(map(int, input().split()))
big = []
Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        for j in range(K):
            Sum += p[i + j]
        if Sum > Max:
            Max = Sum
            index=i
for i in range(K):
    big.append(p[index+i])
ans = []
for i in big:
    kitai=0
    for j in range(1,i+1):
        kitai += j
    kitai = kitai / i
    ans.append(kitai)
print(sum(ans))

Submission status: Time Limit Exceeded

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

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

for i in range(n-k+1):
  if sum(p1[i:i+k]) > ans:
    ans = sum(p1[i:i+k])
   
  
print("{0:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    kitai = [0]*n

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n - k + 1):
        count = 0
        for w in range(i , i + k):
            count += kitai[w]

        ans = max(ans , count)

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(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()))

result = max({sum(p[i:k+i]) for i in range(n-k+1)}) + k
print(result / 2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

exp = 0
for idx in range(len(pi) - (k - 1)):
    tmp = 0
    for num in range(k):
        tmp +=  (pi[idx + num] + 1) / 2
    if exp < tmp:
        exp = tmp

print(exp)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

    e = np.frompyfunc(get_expect, 1, 1)(P)

    t = np.ones((K))

    print(np.max(
        np.convolve(
            e,
            t
        )
    ))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

def e(n):
    ex=(1+n)*n/(2*n)
    return ex
    
ansl=[]
for j in range(n-k+1):
    ex=0
    ans=d[j:j+k]
    ansl.append(ans)

sm=[]
for z in range(n-k+1):
    sm.append(sum(ansl[z]))


mx=max(sm)
ind=sm.index(mx)



ansf=0
for y in range(k):
    ansf+=e(ansl[ind][y])
    
print(ansf)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(str, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    S, T= LS()
    A,B= LI()
    U= input().rstrip()



    if(S==U):
        print(A-1,B)
    else:
        print(A,B-1)


    
    return

# B


def B():
    A=input().rstrip()
    ans='x'
    for i in range(len(A)-1):
        ans+='x'
    print(ans)
        
    


    return

# C


def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def C():
    N = II()
    A=LI()
    AA=set(A)
    if (len(A)==len(AA)):
        print('YES')
    else:
        print('NO')
    return

        


        

# D


def D():

    N,K=LI()
    P=LI()
    tmp=0
    s=0
    for i in range(K,N+1):
        tmp2=sum(P[s:i])
        tmp=max(tmp,tmp2)
        s+=1

    print((tmp+K)/2)
    return

# E


def E():
    N, K = LI()
    A = LI()
    F = LI()
    A.sort(reverse=True)
    F.sort()
    cost = []
    for i in range(len(N)):
        cost.append(A[i]*F[i])

    a = F[cost.index(max(cost))]

    return

# F


def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    N = len(S)

    pass


# Solve
if __name__ == '__main__':

    D()

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
x = list(map(int, input().split()))
wa=0
basyo=0
kotae=0
kari=0
for i in range(A-B+1):
    kari=sum(x[i:i+B])
    if wa<kari:
        wa=kari
        basyo=i
    kari=0

kotae=(wa+B)/2
print(kotae)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = [(int(j) + 1) / 2 for j in input().split()]
li2 = [sum(li[m:m+k]) for m in range(0, len(li) - k + 1, 1)]

print(max(li2))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def solve(_list,_k):
  start = 0
  _sum = -1
  for i in range(len(_list)-_k+1):
    s = np.sum(_list[i:i+_k])
    if _sum < s:
      _sum = s
      start = i

  ans = 0.
  for item in _list[start:start+_k]:
    #upper = np.sum(np.arange(1, item+1))
    ans += (item+1) / 2

  return ans


if __name__ == "__main__":
  _n, _k = map(int, input().split())
  _l = [int(i) for i in input().split()]
  _l = np.array(_l)

  result = solve(_l, _k)
  print(result)

Submission status: Time Limit Exceeded

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

res=[]

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
    res.append(res[i-1]+(sum(range(1,p[i]+1)))/p[i])
ans=res[K-1]

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
#print(N,K)
mytuple= tuple(map(int, input().split()))
tempmax=0
temptuple=()
answer=0

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

Submission status: Time Limit Exceeded

Solution code:
indices_expectation = {}
max_E = 0


def expectation(start_idx, dices):
    result = []
    for i, dice in enumerate(dices):
        if indices_expectation.get(start_idx + i) is None:
            indices_expectation[start_idx + i] = sum(list(range(1, dice + 1))) / dice
        result.append(indices_expectation[start_idx + i])
    return sum(result)


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
p = [int(c) for c in line]

for s_idx in range(0, N - K + 1):
    dices = p[s_idx:s_idx + K]
    E = expectation(s_idx, dices)
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)

Submission status: Time Limit Exceeded

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

max_val = 0
for i in range(0, len(p)-k+1):
  tmp = p[i:i+k]
  val = 0
  for t in tmp:
    y = 0
    for x in range(1, t+1):
      y += x
    val += y / t
  
  if max_val < val:
    max_val = val

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

Submission status: Time Limit Exceeded

Solution code:
nk = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = [0] * (nk[0] + nk[1])

zeros = [0] * nk[1]

seq4search = zeros + p

for i in range(nk[1], nk[0] + nk[1]):
    seq4search[i] = (seq4search[i] + 1) / 2
    ans[i] = sum(seq4search[i - nk[1] + 1:i + 1])

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

print((ans+k)/2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

np_P = np.array(P)

f = lambda x: (x+1)/2
numpy_frompyfunc = np.frompyfunc(f, 1, 1)

a = numpy_frompyfunc(np_P)
v = np.array(K*[1])

print(max(list(np.convolve(a,v, mode='same'))))

Submission status: Time Limit Exceeded

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

  if i == 0:
    ans = sum_
  else:
    if sum_ > ans:
      ans = sum_
    else:
      continue
print(ans)

Submission status: Time Limit Exceeded

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

def main():
    n,k = map(int, input().split())
    l = list(map(mean, input().split()))
    out = 0

    for i in range(len(l)-(k-1)):
        s = sum(l[i:i+k])

        if out < s:
            out = s

    print(out)

def mean(x):
    x = int(x)
    return x * (x+1) / (2 * x)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


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

maxs = max(dp)
index = dp.index(maxs)

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

print(ans)

Submission status: Time Limit Exceeded

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

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

ans = 0
for j in range(max_index, max_index+k):
  su = p[j] * (p[j] + 1) / 2
  ans += su / p[j]
print(ans)

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
lstp = []
for i in range(n-k+1):
    lstp.append(p[i:i+k])
l = [0]*len(lstp)
for i in range(len(lstp)):
    for j in range(k):
        num  = 0.5*(lstp[i][j]+1)
        l[i] += num
print("{:.10f}".format(max(l)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import decimal

n, k = map(int, input().split())
p_list = list(map(int, input().split()))
sum = 0
max = 0
index = 0
value = 0

for i in range(n - k + 1):
    sum = 0
    for j in range(k):
        sum += p_list[i + j]
    if sum > max:
        max = sum
        index = i

for i in range(k):
    for j in range(p_list[index + i]):
        value += (decimal.Decimal(j + 1) / decimal.Decimal(p_list[index + i]))

print(value)

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(" ")]
s = sum(dice_nums[0:0+K])
for i in range(N-K):
    if dice_nums[i] < dice_nums[i+K]:
        new_s = sum(dice_nums[i+1:i+1+K])
        if s < new_s:
            s = new_s
print(s)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
m = []
s = []
j = 0
for i in range(1, 1001):
    j += i
    s.append(j)

for i in range(n-k+1):
    ans = 0
    a = p[i:i+k]
    for b in a:
        ans += s[b-1]/b
    l.append(ans)
print(max(l))

Submission status: Time Limit Exceeded

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

# T[i]に1からiまでの合計値が入っている
# M[i]にiの目があるさいころの期待値が入っている
# T = [0]
# M = [0]
# for j in range(1,1001):
#     T.append(j + T[j-1])
#     K.append(T[j]/j)
# 計算すると(n+1)/2
M = [0]
for j in range(1,1001):
    M.append((j+1)/2)
# print(K)

PP = []
for k in P:
    PP.append(M[k])
ANS = 0
for i in range(N-K+1):
    TEMP = sum(PP[i:i+K])
    if TEMP > ANS:
        ANS = TEMP
print(ANS)

Submission status: Time Limit Exceeded

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

s = []
s.append(0)
j=0
for i in range(1,1001):
    j+=i
    s.append(j/i)

t = []
for i in p:
    t.append(s[i])

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
inp = [0.0]*n
tmp = 0
max = 0
d = list(map(int,input().split()))
for i in range(n):
  for j in range(1,d[i]+1):
    inp[i] += j*(1/d[i])
  tmp += inp[i]
  if i >= m-1:
    if tmp > max:
      max = tmp
    tmp -=inp[i-m+1]

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line

n,k=map(int, input().split())
p=list(map(int, input().split()))
q=[0]*n

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

max=0
for i in range(n-k+1):
    sum=0
    for j in range(i, i+k):
        sum+=q[j]
    if sum > max:
        max=sum
print(max)

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
#t1 = time.time()
A_list = [sum(P_exp[i:i+K]) for i in range(N-K+1)]
"""
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 = [int(_) for _ in input().split()]
p = [int(_) for _ in input().split()]

each_sum_list = []

for i in range(N - K + 1):
    for j in range(K):
        x = 0
        x += p[i + j]
    each_sum_list.append(x)

list_index = each_sum_list.index(max(each_sum_list))

kitaichi = 0

for i in p[list_index:list_index + K]:
    kitaichi += (0.5 * i * (i + 1) / i)

print(kitaichi)

Submission status: Time Limit Exceeded

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

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

t = [0] * K
for l in range(0,K):
     t[l] = (1+m[l])/2
n = sum(t)
print(n)

Submission status: Time Limit Exceeded

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

temp_p = deque([]) 
for i in range(K):
  temp_p.append(p[i])
  sum_m=sum(temp_p)
for j in range(K,N):

  temp_p.popleft()
  temp_p.append(p[j])
  #print(temp_p)
  if(sum(temp_p)>sum_m):
    sum_m=sum(temp_p)
ans=(sum_m/2)+(0.5*K)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
first_int = [int(k) for k in input().split()]
a = first_int[0]
b = first_int[1]
secound_list = [int(k) for k in input().split()]
import numpy as np

def sigm(k):
  return np.sum(np.array(range(k+1)))/k

list_kari = []
for k in range(a):
  a = secound_list[k:k+b]
  c = 0
  for i in a:
    c += sigm(i)
  list_kari.append(c)
  
print(max(list_kari))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

E = np.zeros(N)
for i in range(N):
  E[i] = (P[i]+1) / 2

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def cal_list(list):
    temp = len(list)
    ans = 0
    for i in range(temp):
        ans += sum(range(1,list[i]+1))/list[i]
    return ans

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

for i in range(n):
    try:
        if ans < sum(p[i:i+k]):
            ans = sum(p[i:i+k])
            ans_list = p[i:i+k]
    except:
        pass

print(cal_list(ans_list))

Submission status: Time Limit Exceeded

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

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

i =ppp.index(max(ppp))

tmp = p[i:i+K]

print((sum(tmp)+K)*0.5 )

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
dice = list(map(int, input().split()))#dic=[]

kitai=[]
def calc(n):
    return (n+1)/2

data = list(map(calc, dice))
s=[]

for j in range(N-K+1):
    su=sum(data[j:j+K])
    s.append(su)
print(max(s))

Submission status: Time Limit Exceeded

Solution code:
n,k = input().split()
n = int(n)
k = int(k)
nums = [float(i)/2+0.5 for i in input().split()]
now_list = nums
for i in range(k-1):
  now_list = [j+k for j,k in zip(now_list,nums[i+1::])]
print(max(now_list))

Submission status: Time Limit Exceeded

Solution code:
def calc_ex(x):
  p = 1 / x

  ex_list = list(range(x))
  ex_list = list(map(lambda s: (s + 1) * p, ex_list))

  return sum(ex_list)

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:
import numpy as np

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

x = [(1+i)/2 for i in p]

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

print(res)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = tuple(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 += (1 + p[i]) * (p[i] / 2) / p[i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N, K = map(int, readline().split())
    p = np.array(readline().split(), dtype=np.int32)
    v = np.ones(K)
    q = np.convolve(p, v, mode='vaild')

    print((np.max(q) + K) / 2)


main()

Submission status: Time Limit Exceeded

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

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

max_index = DP.index(max(DP))

kitai=0
for n in range(K):
  kitai += (sum(range(1, P[max_index+n]+1)) / P[max_index+n])
print(kitai)

Submission status: Time Limit Exceeded

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

p_n = input().split()

up_to = n - k + 1

result = 0.0

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

for i in range(up_to):
    sum_ex = 0.0
    for j in range(i,i+k):
        #print(p_n[j])
        sum_ex += p_n[j]
    
    #print(sum_ex)
    if(result < sum_ex):
        result = sum_ex


print('{0:.6f}'.format(result))

Submission status: Time Limit Exceeded

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

for i in range(n[0]):
    p[i]=(p[i]+1)/2
y=[]
for i in range(n[0]-n[1]+2):
    y.append(sum(p[i:i+n[1]]))
print(max(y))

Submission status: Time Limit Exceeded

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

import numpy as np

n, k = na()
p = na()

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