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:
#!/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 = []
    E = []
    for n in range(N):
        if n <= N-K:
            sums.append(sum(P[n:n + K]))
        e = 0.5 * (1 + P[n])
        E.append(e)
    idx = sums.index(max(sums))
    print(sum(E[idx:idx+K]))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = input().split()
b = input().split()

exlist = []

for i in range(int(a[0])):
    exlist.append((1 + int(b[i]))/2)

ans = 0

for i in range(int(a[0])-int(a[1])+1):
    sum = 0
    for j in range(int(a[1])):
        sum += exlist[i+j]
    if ans < sum:
        ans = sum

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ansi = 0
maxtem = 0
for i in range(n - k + 1):
  tem = sum(p[i:i+k])
  if tem > maxtem:
    ansi = i
    maxtem = tem

print((maxtem + k)/2)

Submission status: Time Limit Exceeded

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

import math

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

def expected(x):
    s = 0
    if x % 2 == 1:
        s = x * math.ceil(x / 2)
    else:
        s = (x + 1) * (x / 2)

    return s / x

b = {}
bb = {}
mx = 0

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

    for j in range(K):
        k = i + j
        t += str(k)

    if not t in bb:
        s = 0
        for j in range(K):
            k = i + j
            if not P[k] in b:
                b[P[k]] = expected(P[k])
            s += b[P[k]]
        bb[t] = s

    mx = max(mx, bb[t])

print(mx)

Submission status: Time Limit Exceeded

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

p = list(map(int,input().split()))
q = []
for i in range(n-k+1):
    r = p[i:i+k]
    q.append((sum(r) + k)/2)

print(max(q))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
val_list = []
val_num = N - K + 1

for i in range(val_num):
    val_list.append(sum(p_list[i:i+K]))
max_sum = max(val_list)

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

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

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

e = sum(list(map(lambda x: (1+x)/2,max_list)))
print(e)

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 = 0
    tmp = 0

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

    #print(l)
    k = list(accumulate(range(max(l)+1)))

    for x in l:
        ans += k[x]/x
        
    print(ans)

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
import itertools

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

kukan = 0
kukan_list = deque()
for i in range(k):
    kukan_list.append(p[i])

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


ans = kukan / 2 + 0.5 * k
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#154 d
def kitaichi(x):
    return (x+k)/2

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
    s=0
    s=sum(p[i:i+k])
    if s>=ans:
        ans=s
print(kitaichi(ans))

Submission status: Time Limit Exceeded

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

l = 0
r = k
ansl = 0
ansr = 0
ans=0
for i in range(n - k + 1):
    tmp = sum(p[i:i + k])
    # print(i,i+k,tmp)
    if tmp > ans:
        ansl = i
        ansr = i + k - 1
        ans=tmp
# print(ansl, ansr)
ans2 = 0
for i in range(ansl, ansr + 1):
    ans2 += (p[i] + 1) / 2
print(ans2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
ar = map(int, input().split())
ar = np.array(list(ar))
expect = (ar + 1)/2
sw = np.convolve(expect, np.ones(K, dtype=int), 'valid')
m = np.max(sw)
print(m)

Submission status: Time Limit Exceeded

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

n, k = [int(i) for i in input().split()]
p = [0] * n
for i,v in enumerate(input().split()):
    p[i] = 1.0 + 0.5 * (float(v) - 1.0)

_max_sum = 0
for i in range(n-k+1):
    _sum = sum(p[i:i+k])
    if _sum >= _max_sum:
        _max_sum = _sum
print(_max_sum)

Submission status: Time Limit Exceeded

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

#check max

max=0
imax=0
for i in range(N-K+1):
  temp = sum(Pi[i:i+K])
  if max < temp:
    max = temp
    imax = i

ans=0
for i in range(imax,imax+K):
  ans +=(1/2)*(Pi[i]+1)
  
print(ans)
#n/2(n+1) / n = 1/2 (n+1)

Submission status: Time Limit Exceeded

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

p_list = [ int(p) for p in input().split(' ')]

e_max = 0

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

print(float(e_max)/2 + float(k)/2)

Submission status: Time Limit Exceeded

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

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n

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

    for i in range(n - k + 1):

        count = sum(kitai[i:i+k])
 #       for w in range(i , i + k):
#            count += kitai[w]
#            count += tasu(p[w]) / p[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:
import math

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

count = 0
MaxSum = 0

for i in p:
    tmp_slice = p[count:count + K]
    if MaxSum < sum(tmp_slice):
        MaxSum = sum(tmp_slice)
    count += 1 

print((MaxSum+K)/2)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    a = [(i/2 + 0.5) for i in A]
    ans = 0
    for i in range(N-M+1):
        ans = max(ans, sum(a[i:M+i]))

    return ans

print(solve())

Submission status: Time Limit Exceeded

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

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

  tmp = p[ind:ind+K]

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = [i for i in map(int, input().split())]
items = []
for i in range(n):
  items += sum(l[i:i+k]),
print((max(items)+k)/2)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split()) #n=10, k=4
li = list(map(int,input().split()))
value = 0
max = 0
place = []
sum_p=0
for i in range(n-k+1): #10 - 4 + 1 = 7
    value = (sum(li[i:i+k]))#sum(li[0:4]),sum(li[1,5])...sum(li[6:10])
    if value > max:
        max = value
        place = li[i:i+k]

for i in place:
    sum_v = 0
    for v in range(1,i + 1):
        sum_v += v
    sum_p += sum_v / i
print(sum_p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

maxval = 0
idx = 0
for ii in range(N):
  
  p[ii] = int(p[ii])
  if ii - K >= 0:
    val = np.sum(p[ii-K+1:ii+1])
    if val > maxval:
      maxval = val
      idx = ii

ans = 0
for ii in range(idx-K+1,idx+1):
  an = np.arange(1,p[ii]+1)
  ans += np.sum(an)/p[ii]

#ans = 1*1/6 + 2*1/6 + 3*1/6 + 4*1/6 + 5*1/6 + 6*1/6
#ans = 1/2 + 2/2 + 1/4 + 2/4 + 3/4 + 4/4 + 1/5 + 2/5 + 3/5+ 4/5 + 5/5
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from itertools import accumulate

    def e(dice):
        return sum([r / dice for r in range(1, dice+1)])

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

    p_cum = [0] + list(accumulate(p))

    ma = 0
    ind = 0
    for i in range(k, n+1):
        temp = p_cum[i] - p_cum[i-k]
        if ma < temp:
            ma = temp
            ind = i

    x = p[ind-k:ind]

    print(sum(e(d) for d in x))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
x=np.array(w)
for i in range(q[0]-q[1]+1):
  k=0
  for j in range(q[1]):
    k+=x[i+j]
  if a<k:
    a=k
    memo=i
print((a+q[1])/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
class Dice():
    def __init__(self, N, K):
        self.ex = 0.0
        self.N = N
        self.K = K
        self.max = 0

    def calc_ex(self, P):
        i = 0
        end = self.K
        while i + end <= self.N:
            check_num = P[i:i + end]
            total_num = sum(check_num)
            if total_num > self.max:
                self.max = total_num
                self.ex = 0
                for j in check_num:
                    self.ex += (j + 1) / 2
            i += 1
        return


N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
dice = Dice(N, K)
dice.calc_ex(P)
print("%.12f" % dice.ex)

Submission status: Time Limit Exceeded

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

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

start=0
wa=0
for i in range(N-K+1):
    temp=sum(P[i:i+K])
    if wa <= temp:
        start=i
        wa=temp

ans=0
for i in P[start:start+K]:
    ans+=s(i)
print(ans)

Submission status: Time Limit Exceeded

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

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


#print((sumn+0.5*k)/2)

for i in p[ind:ind+k]:
    ans += (i+1)/2
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
# P = np.array([int(i) for i in input().split()])
P = np.array([float(i)/2.0*(float(i)+1.0)/float(i) for i in input().split()])
ev_sums = np.zeros(N - K + 1)
for i in range(len(ev_sums)):
    ev_sums[i] = np.sum(P[i:i+K])

print(np.max(ev_sums))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def calc(n):
    return (n+1)/2
t1=time.time()
data = list(map(calc, dice))
t2=time.time()
t3=time.time()
p=0
for j in range(N-K+1):
    su=sum(data[j:j+K])
    if su>p:
        p=su
t4=time.time()
print(p)

Submission status: Time Limit Exceeded

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

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

_ans = p[0:k]

ans = sum(_ans)

for x in range(k,n):
    _ans.pop(0)
    _ans.append(p[x])
    # print(_ans)
    ans = max(ans, sum(_ans))

print(ans)

Submission status: Time Limit Exceeded

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

def kitaichi(n):
	ret = 0
	for i in range(n+1):
		ret += i
	return ret / n

ans = 0
for i in range(len(p)):
	pp = p[i:i+k]
	if len(pp) != k: break
	tmp = 0
	for j in pp:
		tmp += kitaichi(j)
	ans = max(ans, tmp)


print(ans)

Submission status: Time Limit Exceeded

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

dices =[]
dicesSum=[]
for i in range(N-K+1):
    l= ps[i:i+K]
    dices.append(l)
    dicesSum.append(sum(l))

max_value = max(dicesSum)
max_index = dicesSum.index(max_value)

exp=0
for p in dices[max_index]:
    exp += 0.5*p +0.5
print(exp)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
P = list(map(int, input().split()))
#n = 10
#k = 4
#P = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
ans2 = list()
for i in range(n - (k-1)):
    ans2.append(P[i:i+k])
#print(ans2)

ans3 = list()
for i in ans2:
    ans3.append(sum(i))
#print(ans3)

am = np.argmax(ans3)
#print(am)
am2 = P[am:am+k]
#print(am2)

ans = 0
for i in am2:
    for j in range(1, i + 1):
        ans += j / i
print(ans)

Submission status: Time Limit Exceeded

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

max_average = 0
point = 0
for i in range(len(P)-K+1):
    check = 0
    for j in range(K):
        check += P[i+j]

    if check > max_average:
        max_average = check
        point = i
        
count = 0
for p in range(point, point+K):
    count += sum(range(1, P[p]+1)) / P[p]

print(count)

Submission status: Time Limit Exceeded

Solution code:
import time
N, K = map(int, input().split())
A = list(map(int, input().split()))

def CalExVal(x):
    return (1/2*(x+1))
Ex = list(map(CalExVal, A))
adjlist = [0]*(len(A)-K+1)

for i in range(len(A)-K + 1):
    adjlist[i] = sum(Ex[i:(K+i)])

print(max(adjlist))

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
    expv=0
    for j in range(K):
        expv+=P[i+j]
    maxv=max(maxv,expv)
    
        
print(maxv)

Submission status: Time Limit Exceeded

Solution code:
all,rolls=map(int,input().split())
List=list(map(int,input().split()))

sum = 0
sumList =[]

for i in range(all - rolls + 1):
	all_sum = 0
	for j in range(rolls):
		sum = (List[i + j] + 1) / 2
		all_sum = all_sum + sum
	sumList.append(all_sum)

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

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

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

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 = (p[pos+i]+1)*p[pos+i]/2
  kitaichi = kitaichi + float(temp/p[pos+i])
  
print('{:.12f}'.format(kitaichi))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def Ex(n):
  return 0.5*(1+n)
 
out = [0]*K
_sum = [0]*K
_max = 0
for i in range(N):
  curr = Ex(ps[i])
  tmp = _sum[-1] - out[0] + curr
  _max = max(_max, tmp)
  
  out = out[1:] + [curr]
  _sum = _sum[1:] + [tmp]
print(_max)

Submission status: Time Limit Exceeded

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

def kitai(x):
	sum = x*(1+x)/2
	return sum/x

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

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(lambda x : (x+1)/2, b))
d = a[0] - a[1]
e = 0
f = []
for i in range(0,d+1):
	if e < sum(c[i:i+a[1]]):
		e = sum(c[i:i+a[1]])
	else:e = e
print(e)

Submission status: Time Limit Exceeded

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

s = []
for i in range(1001):
    s.append(0.5+(0.5*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, k = list(map(int, input().split()))
P = list(map(int, input().split()))

dp = [0] * n
m = {}

def func(x):
    return m.get(x, sum(range(x+1)) / x)
    #return sum(range(x+1)) / x

for i in range(n):
    if i - k >= 0:
        dp[i] = dp[i - 1] - func(P[i - k]) + func(P[i])
    else:        
        dp[i] = sum([func(p) for p in P[:i + 1]])

print(max(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

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]
  
ans, num = 0, 0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K = map(int, input().split())
x = np.array(list(map(int, input().split())))

m = 0

for i in range(N-K+1):
	ans = 0
	for j in range(i, i+K):
		ans += np.sum(np.array(range(1, x[j]+1))) / x[j]

	if ans > m:
		m = ans

print(m)

Submission status: Time Limit Exceeded

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

c = N - K + 1
dp = [0 for _ in range(c)]

for i in range(c):
    dp[i] = sum(map(lambda x: sum(range(1, int(x) + 1)) / x, P[i: i + K]))

print('{:.10f}'.format(max(dp)))

Submission status: Time Limit Exceeded

Solution code:
a = [int(b) for b in input().split()]
l = input().split()
l = [int(n) for n in l]
b = a[0] - a[1]+1


maximum = 0
for i in range(b):
  n = sum(l[i:i+a[1]])
  if n > maximum:
    maximum = n
    
print(0.5*(maximum+a[1]))

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from itertools import accumulate

    def e(dice):
        return sum([r / dice for r in range(1, dice+1)])

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

    p_cum = [0] + list(accumulate(p))

    ma = 0
    ind = 0
    for i in range(k, n+1):
        if ma < p_cum[i] - p_cum[i-k]:
            ma = p_cum[i] - p_cum[i-k]
            ind = i

    x = p[ind-k:ind]

    print(sum(e(d) for d in x))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = 0
ind = 0
i = 0
while True:
    s = sum(ilist[i:i+K])
    if s > max_dice:
        max_dice = s
        ind = i
    if i <= N-K-2:
        if ilist[i] >= ilist[i+K]:
            i += 2
        elif ilist[i] < ilist[i+K]:
            i += 1
    elif i <= N-K-1:
        i += 1
    elif i == N-K:
        break     
max_p = (sum(ilist[ind:ind+K])+K)/2
print(max_p)

Submission status: Time Limit Exceeded

Solution code:
def expected_value(x):
    e = 0
    for i in range(1, x+1):
        e += i / x
    return e

n, k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
evs = list()
for i in p:
    evs.append(expected_value(i))

# initialize
left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))

Submission status: Time Limit Exceeded

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

maxList = []
kitaichi = 0
for index in range(len(p)):
  if sum(p[index:index+K]) > sum(maxList):
    maxList = p[index:index+K]

for index in range(len(maxList)):
  i = 1
  s = 0
  while i <= maxList[index]:
    s += i
    i += 1
  kitaichi += s / maxList[index]

print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, k = map(int, input().split())
P = np.array(input().split(), dtype=int)
template = np.ones(k)

a = np.convolve(P, template, mode="valid")

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

Submission status: Time Limit Exceeded

Solution code:
def main():
  dice_count = int(input().split()[1])
  max_index = 0
  max_point = 0
  values = input().split()
  for i in range(len(values) - dice_count + 1):
    temp = 0
    for j in range(dice_count):
      temp += int(values[i + j])
    if temp > max_point:
      max_point = temp
      max_index = i
  
  result = dice_count
  for i in range(dice_count):
    temp = int(values[max_index + i]) - 1
    result += temp * 0.5
  
  print(result)
  
main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, K = map(int, input().split())
np_P = np.array(list(map(int, input().split())))

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

a = numpy_frompyfunc(np_P)
v = np.ones(K)

print(np.amax(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()))
MAX = 0
for i in range(N-K+1):
    tmp = sum(P[i:i+K])
    if MAX < tmp:
        MAX = tmp
print((MAX+K)/2)

Submission status: Time Limit Exceeded

Solution code:
def resolve_D():
    max_ = 0
    res = 0
    n, k = map(int, input().split())
    l = list(map(int, input().split()))
    for i in range(0, n-k+1):
        total = sum(l[i:i+k])
        if total > max_:
            max_ = total
            max_i = i
    for j in l[max_i:max_i+k]:
        res += sum([i for i in range(1, j+1)]) / j
    print(res)
resolve_D()

Submission status: Time Limit Exceeded

Solution code:
import sys
from itertools import accumulate
import numpy as np


def solve():
    N, K, *P = map(int, sys.stdin.read().split())
    n = np.convolve(np.array(P), np.ones(K), mode='valid').argmax()
    cusum = tuple(accumulate(range(1000+1)))
    return sum(cusum[i] / i for i in P[n:n+K])


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

Submission status: Time Limit Exceeded

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

c=0

x=0

for i in range(1,n-k+1):
#  print(sum(p[x:x+k]),sum(p[i:i+k]))
  if sum(p[x:x+k])<sum(p[i:i+k]):
    x=i
#print(x)
for i in range(x,x+k):
  z=0
  for j in range(0,p[i]+1):
    z+=j
#  print(z)
#  print(p[i])
  c+=z/p[i]
print(c)

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

all_sigm = [sigm(k) for k in secound_list]
all_sigm_ = 0
for k in range(a):
  kari = sum(all_sigm[k:k+b])
  if all_sigm_<= kari:
    all_sigm_ = sum(all_sigm[k:k+b])
  
print(all_sigm_)

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
l=[]
for i in range(N-K+1):
  l.append(sum(p[i:i+K]))
print(max(l))

Submission status: Time Limit Exceeded

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

prev = sum(p[1:k])
ind = 0


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

    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:
def calc(num):
    return num * (num + 1) / 2 * (1 / num)

N, K = [int(i)for i in input().rstrip().split(' ')]
_p = [int(i)for i in input().rstrip().split(' ')]
ret = []
v = N-K+1
let = [calc(i) for i in _p]
for i in range(v):
    sums = 0;
    for j in range(i, i+K):
        sums += let[j]
    ret += [sums]

print(max(ret))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

max_val = 0
d = deque(maxlen=K)
for n in Ps:
    d.append(n)
    val = sum(d)
    if max_val < val:
        max_val = val
print((max_val+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):
    res = (sum(P[i: i + K]) + K) / 2
    if res < ans:
        continue
    else:
        ans = res
print(ans)

Submission status: Time Limit Exceeded

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

e_nums = [(i+1)/2 for i in nums]

max_sum = 0
for i in range(n):
  if i+k <= n:
    max_sum = max(max_sum, sum(e_nums[i:i+k]))

print(max_sum)

Submission status: Time Limit Exceeded

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

TEMP = []
for i in range(N-K+1):
    TEMP.append(sum(P[i:i+K]))
ANS = max(TEMP)
print((ANS+K)/2)

Submission status: Time Limit Exceeded

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

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

ans=0
for i in range(cnt, cnt+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 = list(map(int, input().split()))
P = list(map(int, input().split()))

dp = [0] * n

def func(x):
    return sum(range(x+1)) / x

for i in range(n):
    if i - k >= 0:
        dp[i] = dp[i - 1] - func(P[i - k]) + func(P[i])
    else:
        dp[i] = sum([func(p) for p in P[:i + 1]])

print(max(dp))

Submission status: Time Limit Exceeded

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

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        now_sum += p_list[p_i + i]

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = []
for i in range(k):
    max_scope_list.append(p_list[scope_index + i])

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

Submission status: Time Limit Exceeded

Solution code:
input_line = [int(i) for i in input().split(" ")]
k = input_line[1]

input_line = [(int(i) + 1) / 2 for i in input().split(" ")]

max_excepted_value = 0
for i in range(len(input_line) - k + 1):
    sum_excepted_value = sum(input_line[i: i+ k])
    if max_excepted_value < sum_excepted_value:
        max_excepted_value = sum_excepted_value
print(max_excepted_value)

Submission status: Time Limit Exceeded

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

p = input().split()

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

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

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-k+1):
    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:
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
ans = 0.0

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

print(ans)

Submission status: Time Limit Exceeded

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

maxN=0
for i in range(N-K+1):
  sumN=0
  for j in range(K):
    sumN=sumN+(P[i+j]+1)/2
  if sumN>=maxN:
    maxN=sumN
print(maxN)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]

c = np.array([sum(b[i:i+a[1]]) for i in range(0, len(b) - a[1] + 1)])
d = c.argmax()
e = b[d:d+a[1]]
f = sum([sum(range(1, d + 1)) / d for d in e])

print(f)