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 = [int(n) for n in input().split()]
P =  [int(n) for n in input().split()]
o = {}
for i in range(1,1001):
    o[i] = sum([(j/i) for j in range(1,i+1)])
ans = 0
for k in range(N-K+1):
    m = sum([o[x] for x in P[k:k+K]])
    if m > ans:
        ans = m
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda x: sum(x)/len(x)+1, map(range, dices)))
s = prev = sum(avg[0:t])

for i in range(1, n-t+1):
  prev = prev - avg[i-1] + avg[i+t-1]
  s = max(s, prev)
print(s)

Submission status: Time Limit Exceeded

Solution code:
def calc_ex(x):
  ex = (1 + x) / 2
  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))

ans_list = [0]

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



print(sum(list(map(calc_ex, ans_list))))

Submission status: Time Limit Exceeded

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

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

print((k+ans)/2)

Submission status: Time Limit Exceeded

Solution code:
def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
maxsize = sum(P[0:K])
for i in range(N-K):
    if P[i]>P[i+K]:
        pass
    else:
        if sum(P[i+1:i+K+1]) > maxsize:
            maxsize = sum(P[i+1:i+K+1])
print('{:.7f}'.format(maxsize))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
for j in range(0, k-1):
  p[j]=(p[j]+1)*p[j]/(p[j]*2)#p[i]が期待値になった
list00=[]
for i in range(k-1, n):
  p[i]=(p[i]+1)*p[i]/(p[i]*2)#p[i]が期待値になった
  list00.append(sum(p[i-k+1:i+1]))
list00.sort()
print(list00[n-k])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(max(r))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import numpy as np
def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = np.asarray(list(map(int,input().split())))

    max_sum = 0
    listN = list(range(N))
    for i in listN:
        tmp_sum = np.sum(p_list[i:i+K])
        if(max_sum < tmp_sum):
            max_sum = tmp_sum
            ichi = i

    kitaichi = ((p+1)/2 for p in p_list[ichi:ichi+K])

    print(sum(kitaichi))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

def main():
    N,K = list(map(int, input().split()))
    p = list(map(int, input().split()))
    n = N-K+1
    max = 0
    for i in range(N-K+1):
        tmp = ((sum((p[i:i+K]))+K)*0.5)
        if(max < tmp):
            max = tmp
    print('{:.12f}'.format(max))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

max = 0
tmp = 0
i = 1
j = 0
start = 0
sum = 0

#print(n[0]-3)

while(j <= n[0]-n[1]):
    start = j
    for i in range(n[1]):
        #print(start)
        for k in range(1,p[start]+1):
            sum += k
        tmp = tmp + (sum/p[start])
        start = start + 1
        sum = 0
    if(max < tmp):
        max = tmp
    #print("------")
    tmp = 0
    sum = 0
    i = 1
    j = j + 1


print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
ans = 0
for j in arr[max_i:max_i+k]:
    ans += sum(range(1, j+1)) / j
print(ans)

Submission status: Time Limit Exceeded

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

p = tuple(p)
max_r = 0
max_i = 0
pre = 0
for i in range(n-k+1):
  if pre > p[i+k-1]:
    pre = p[i]
    continue
  r = sum(p[i:i+k])
  pre = p[i]
  
  if r > max_r:
    max_r = r
    max_i = i
    
max_e = 0
for j in range(max_i, max_i+k):
  max_e += (p[j]+1)/2

print(max_e)

Submission status: Time Limit Exceeded

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

pp = len(p)
ll = []
for i in range(0, pp - k + 1):
  ll.append(sum(p[i:i+k]))

print(max(ll))

Submission status: Time Limit Exceeded

Solution code:
numbers = list(map(int, input().split()))
number = numbers[0]
neighbor = numbers[1]
maxes = list(map(int, input().split()))

exes = list()
for maxe in maxes:
    temp=(maxe+1)/2
    exes.append(temp)

max_exes = list()
for i in range(len(exes) - neighbor + 1):
    temp = exes[i]
    for j in range(1, neighbor):
        temp = temp + exes[i + j]
    max_exes.append(temp)
ans = '{:.12f}'.format(max(max_exes))
print(ans)

Submission status: Time Limit Exceeded

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

#ABC153D


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


x = 0
for i in range(k-1, n):
	s = 0
	tmp = []
	for j in range(i-(k-1), i+1):
		tmp.append(p[j])
		s += p[j]
	if x < s:
		x = s
		y = tmp

ans = 0
for i in y:
	a = 0
	if i % 2 == 0:
		a = (i*i+i)/2
	else:
		b = int(i/2)
		a = b*2 + 1 + b*i
	ans += a / i

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

p = input().split()
p = np.array(list(map(int,p)))
q = p/2

e_max = 0
for i in range(n-k+1):
  e = np.sum(q[i:i+k]) + 0.5 * k
  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())
p=list(map(int,input().split()))
r=[]
q=0
for i in range(n-k+1):
    r.append(sum(p[i:i+k]))
s=r.index(max(r))
for i in range(s,k+s):
    q+=(p[i]+1)/2
print(q)

Submission status: Time Limit Exceeded

Solution code:
def fil(list):
  a = 0
  for i in list:
     a += 0.5 + 0.5 * i
  return a

n, k = map(int, input().split())
p = list(map(int, input().split()))
ll = []
pp = len(p)
for i in range(0, pp - k + 1):
  ll.append(fil(p[i:i+k]))

print(max(ll))

Submission status: Time Limit Exceeded

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

s = [0]*n
hai = [0]*n
max = 0

for i in range(n):
  hai[i] = (sum(range(int(tmp[i])))+int(tmp[i]))/int(tmp[i])
for i in range(n):
  for j in range(k):
   t = sum(hai[(i-j):(i+k-j)])
   if max < t :
      max = t
print(max)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc154/tasks/abc154_d
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = input().split()
for i in range(N):
  p[i] = int(p[i])
E = []
A = []
# for k in range(N):
#   E.append(0)
#   for i in range(1,p[k]+1):
#     E[k] = E[k]+i/p[k]
# for i in range(N-K+1):
#   kitai = 0
#   for k in range(K):
#     kitai = kitai + E[k+i]
#   A.append(kitai)

for i in range(N-K+1):
  syoukei = 0
  for k in range(K):
    syoukei = syoukei + p[k+i]
  A.append(syoukei)
max_value = max(A)
start = A.index(max_value)
ans =0
for i in range(start,start+K):
  for k in range(1,p[i]+1):
    ans = ans + k/p[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections

N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
A=(N-K+1)
for i in range(A):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count.keys())
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)

Submission status: Time Limit Exceeded

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

a = [(1+p[i])/2 for i in range(n)]
res = sum(a[0:k])

for i in range(k,n):
    if a[i-k]<a[i]:
        cnd=sum(a[i-k+1:i+1])
        if cnd>res:
            res = cnd


print(res)

Submission status: Time Limit Exceeded

Solution code:
N,K,*P = map(int,open(0).read().split())

m = 0
maxIdx = 0
for i in range(0,N-K+1):
  sa =sum(P[i:i+K])
  if m < sa:
    m = sa
    maxIdx = i
ans = 0
for i in range(K):
  ans += (P[maxIdx+i]+1)/2
print(ans)

Submission status: Time Limit Exceeded

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

i=0
r=0
g=0

while(i<n-k+1):
  g=i
  while(g<i+k):
    a=list[g]
    j=1
    while(j<=a):
      x=1/a*j
      r+=x
      j+=1
    g+=1
  rlist.append(r)
  r=0
  i+=1
print(max(rlist))

Submission status: Time Limit Exceeded

Solution code:
a, b= map(int, input().split())
*l, = map(int, input().split())
A = []
for i in range(a):
  A.append(sum(l[i:i+b])) 
B = (max(A))/2 + b/2
print(float(B))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

all_sigm = [sigm(k) for k in secound_list]
all_sigm_ = [sum(all_sigm[k:k+b]) for k in range(a)]
print(max(all_sigm_))

Submission status: Time Limit Exceeded

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

max_kitai = 0
for x in range(n-k+1):
    current_value = (sum(data[x:x+k]) + k)/2
    if max_kitai < current_value:
        max_kitai = current_value

print(max_kitai)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
start = 0
Max = 0
P = [int(s) for s in input().split()]
while N >= K:
  part = P[start:K]
  tempMax = sum(part)
  if tempMax > Max:
    Max = tempMax
    partMax = part
  start = start + 1
  K = K + 1
  
sumMax = []
for i in partMax:
  sump = sum(p+1 for p in range(int(i)))
  sumMax.append(sump/int(i))
print(sum(sumMax))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split())) 

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


print("{:.12f}".format((max(l)+K) /2))

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=(sum(P[i:i+K])+K)/2
  if sumN>=maxN:
    maxN=sumN
print(maxN)

Submission status: Time Limit Exceeded

Solution code:
N, K = input().split(" ")
pList = input().split(" ")

maxEx = 0

# 期待値
for index, k in enumerate(pList):
    kList = pList[index:index + int(K)]

    if int(K) != len(kList):
        break

    eX = 0
    
    for element in kList:
        eX += sum([n for n in range(1, int(element) + 1)]) / int(element)
    
    if maxEx < eX:
        maxEx = eX

print(maxEx)

Submission status: Time Limit Exceeded

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


maxnum=0
index=0
num=0
for i in range(len(P)):
    num+=P[i]
    if maxnum<num:
        maxnum=num
        index=i




    if i>=K-1:
        num-=P[i-(K-1)]


List=[]
for i in range(K):
    x1=P[index-i]
    sumx1=sum([j for j in range(1,x1+1)])


    sumx1=sumx1/x1
    List.append(sumx1)


print(sum(List))

Submission status: Time Limit Exceeded

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

sum_max = max([sum(nums[i:i+k]) for i in range(n-k+1)])

print((sum_max +k)/2)

Submission status: Time Limit Exceeded

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

#期待値
for t in p:
    value = 0
    for x in range(t+1):
        value += x/t
    E.append(value)

for t in range(N-(K-1)):
    value = 0
    for i in range(K):
        value += E[t+i]
    expectation.append(value)

output = sorted(expectation,reverse=True)
print(format(output[0],'.12f'))

Submission status: Time Limit Exceeded

Solution code:
def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
maxsize = sum(P[0:K])
for i in range(N-K):
    if P[i]>P[i+K]:
        pass
    else:
        if sum(P[i+1:i+K+1]) > maxsize:
            maxsize = sum(P[i+1:i+K+1])
print(maxsize)

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:
def cal_ans(x):
    ans = (x*(x+1)/2)/x
    return ans
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = list(map(cal_ans,p))

ans_temp = 0
ans_list = []
for i in range(n-k+1):
    ans_list.append(sum(p[i:i+k]))
print(max(ans_list))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = input().split()
d = []
for i in range(a - b + 1):
	h = 0
	for j in range(b):
		h += int(c[i + j])
	d.append(h)
e = 0
g = d.index(max(d))
for i in range(b):
	f = int(c[i + g])
	d = 0
	for j in range(f):
		d += (j + 1)
	e += d / f
print(e)

Submission status: Time Limit Exceeded

Solution code:
#import heapq

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

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

m = 0
l = []
for i in range(n-k+1):
    t = sum(p[i:i+k])
    if(m <= t):
        l = p[i:i+k]
        m = t
#print(l)
#l = heapq.nlargest(k, p)
#print(l)


dist = {}
res = 0
for i in l:
    if i in dist:
        ans = dist[i]
    else:
        dist[i] = dice(i)
    res += dice(i)

print(res)

Submission status: Time Limit Exceeded

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

mres=0;cur=0
for i in range(n-k+1):
	cur=0
	for j in range(i,i+k):
		x = a[j]
		cur+= (1/x) * (x*(x+1))/2
	
	if cur> mres:
		mres=cur
		
print(mres)

Submission status: Time Limit Exceeded

Solution code:
n,k = (int(x) for x in input().split())
list = list(map(int, input().split()))
max = 0
min=1000000000000000000000
if k<=n/2:
	for i in range(0,n-k+1):
		su = sum(list[i:i+k])
		if su>max:
			max=su
	print((max+k)/2)
else:
	for i in range(0,n-k+1):
		su = sum(list[0:i])
		su+=sum(list[i+k:])
		if su<min:
			min=su
	print((sum(list)-min+k)/2)

Submission status: Time Limit Exceeded

Solution code:
def ex_value(dice):
  n = 0
  for i in range(1,dice+1):
    n += i*1/dice
  return(n)
def main():
  n,k = map(int, input().split())
  list_p = list(map(int, input().split()))
  list_ex_val = list(map(ex_value, list_p))
  print(max([sum(list_ex_val[i:i+k]) for i in range(n-k+1)]))
     
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int, input().split()))
p = list(map(int, input().split()))
lists = list()
x = n[0] - n[1] + 1

for i in range(x):
  lists.append(sum(p[i:i+n[1]]))

print ((n[1] + max(lists)) /2)

Submission status: Time Limit Exceeded

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

sum = 0
for i in range(n-k+1):
  s = np.sum(p[i:i+k])
  if s > sum:
    l =p[i:i+k]
    sum = s

sum = 0
for i in range(k):
  sum += (l[i]/2)+0.5
  
print(sum)

Submission status: Time Limit Exceeded

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

p = np.array(p)
max_sum = 0
ind = 0
for i in range(n-k+1):
    tmp_sum = np.sum(p[i:i+k])
    if(max_sum < tmp_sum):
        max_sum = tmp_sum
        ind = i

nums = p[ind: ind+k]

r = sum(list(map(lambda num: num / 2 + 0.5, nums)))

print(r)

Submission status: Time Limit Exceeded

Solution code:

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

def gokei(x):
    return x * (x+1) / 2

for i in range(n-k+1):
    tmp = 0
    for j in range(i,i+k):
        tmp += gokei(p[j])/p[j]
    if ans <= tmp:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(num) for num in input().split(' ')]
As = [(float(num)+1.0)/2.0 for num in input().split(' ')]
 
max_ = -1.0
window = []
 
for i in range(K):
	A = As[i]
	window.append(A)
	if max_ < sum(window):
		max_ = sum(window)
	
 
for j in range(K,N):
	window.pop(0)
	A = As[j]
	window.append(A)
	if max_ < sum(window):
		max_ = sum(window)
 
print(max_)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = tuple(map(int,input().split()))

    max_sum = 0
    listN = list(range(N))
    for i in listN:
        tmp_sum = sum(p_list[i:i+K])
        if(max_sum < tmp_sum):
            max_sum = tmp_sum
            ichi = i

    kitaichi = ((p+1)/2 for p in p_list[ichi:ichi+K])

    print(sum(kitaichi))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
max = 0
index = 0
res = 0

a = n - k + 1
b = k

for i in range(a):
    for j in range(b):
        score.append(List[i+j])
    pre = sum(score)

    if max < pre:
        max = pre
        index = i
        pre = 0
    else:
        pre = 0
    score.clear()

for i in range(index, index+k):
    res += 1 + 0.5 * (List[i]-1)

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += (1+p[i-1])/2
    return s
  
M = max(sigma(i, i+k-1) for i in range(1, n-k+2))
print(M)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
list=list(map(int, input().split()))
a=[]
for i in list:
    a.append(sum(range(i+1))/i)
b=[]
ma=0
for i in range(N+K-1):
    ma = max(ma, sum(a[i:i+K]))
print(ma)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    Max = 0
    Max1 = 0
    for i in range(N-K+1):
        Max1 = 0
        for k in range(i,i+K):
            Max1 += (p[k]+1)/2
        if Max1 > Max:
            Max = Max1
    print(Max)
main()

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = (((P*(P+1)/2))/P)
    kitaichi.append(kitai)
ans = []
for j in range((n-k)+1):
    a = sum(kitaichi[j:j+k])
    ans.append(a)
ans.sort(reverse=True)

print(ans[0])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def expected_value(me):
  return ((1/2)*me*(me+1))/me

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

kaisu = n-k + 1
point = 0
res = 0
for j in range(kaisu):
  temp = np.sum(num_p[j:j+k])
  if res < temp:
    res = temp
    point = j

print(np.sum(expected_value(num_p[point:point+k])))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
def calc_expected(c):
    ans = 0
    for i in range(c):
        ans += (i+1) * (1 / c)
    return ans

a, b = map(int, input().split())
expected = 0
tmp_expected = 0
li = list(map(int, input().split()))
li2 = []

for i in range(a):
    li2.append(li[i])

length = len(li2)

for s in range(length):
    tmp_expected = 0
    for i in range(b):
        if s+i >= length:
            break
        tmp_expected += calc_expected(li2[s+i])

    if tmp_expected >= expected:
        expected = tmp_expected

print(expected)

Submission status: Time Limit Exceeded

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

    tmp = 0
    tmp_arr = []
    sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
    max_v = max(sum_tmp)
    max_i = sum_tmp.index(max_v)
    ans = 0
    for j in arr[max_i:max_i+k]:
        ans += sum(range(1, j+1)) / j
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def ex(x):
    s = 0
    p = 1/x
    for i in range(1, x+1):
        s = s + p*i
    return s

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

m = 0
px = list(map(ex, p))

for j in range(n-k+1):
    sum = 0
    for i in range(j, j+k):
        sum = sum + px[i]
    m = max(sum, m)

print(m)

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())))
p_exp= (p+1)/2

exp=[]
for i in range(N-K+1):
    e=sum(p_exp[0+i : K+i])
    exp.append(e)
print(max(exp))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
P = list(map(int, input().split()))

ans2 = list()
for i in range(n - (k-1)):
    ans2.append(P[i:i+k])
ans = 0
ans5 = list()

for i in ans2:
    ans = 0
    for j in i:
        for k in range(1, j + 1):
            ans += k / j
    ans5.append(ans)
print(max(ans5))

Submission status: Time Limit Exceeded

Solution code:
from itertools import count, islice

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

s_dice = dict()
s_dice[1] = 1
for i in range(2, max(dice) + 1):
    s_dice[i] = s_dice[i - 1] + i

p_dice = [s_dice[e] / e for e in dice]
print(max([sum(p_dice[i:i+k]) for i in range(0, n - k + 1)]))

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()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    if i < k_range-1:
        e_list[i] = calc_expected_value(p[i])
    elif i == k_range-1:
        e_list[i] = calc_expected_value(p[i])
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        e_list[i] = calc_expected_value(p[i])
        # ans = max(ans, sum([e_list[i-k] for k in range(k_range)]))
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

Submission status: Time Limit Exceeded

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

N = Input[0]
K = Input[1]

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

Inp_ar = Input

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

add=0
cnt=0

for i in range(N-K+1):
  add = sum(Inp_ar[i:i+K])
  if add>cnt:
    cnt = add

print(cnt)

Submission status: Time Limit Exceeded

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

box = [0]*(n-k+2)

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

Submission status: Time Limit Exceeded

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

bigNumber = 0

for i in range(x-y+1):

    number = sum(p[i:i+y])

    if number > bigNumber:
        bigNumber = number

print((bigNumber + y) / 2)

Submission status: Time Limit Exceeded

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

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 = (total_num + end)/2
                # 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:
import numpy as np

def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")

    ps_means = np.zeros(N)
    maxval = 0

    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            sumval = np.sum(ps_means[i-K+1:i+1] / ps[i-K+1:i+1])
            if sumval > maxval:
                maxval = sumval

    ans = maxval
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


def solve(N: int, K: int, p: "List[int]"):
    max = -1
    arr_max = []
    for i, v in enumerate(p):
        arr = p[i:i+K]
        m = sum(arr)
        if m > max:
            max = m
            arr_max = arr
    print(sum([calc(i) for i in arr_max]))


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


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

def gokei(x):
    return x * (x+1) / 2

for i in range(n-k+1):
    tmp = 0
    for j in range(i,i+k):
#        print(j)
        tmp += gokei(p[j])/p[j]
#    print(tmp)
    if ans <= tmp:
        ans = tmp
ans = float(ans)

print(ans)

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: (int(x)+1)/2, input().split()))
dp=0
best_i = 0
for i in range(N):
    if sum(lis_p[i:i+K]) >= dp:
        best_i = i
    dp = max(sum(lis_p[i:i+K]), dp)
res = sum(list(map(lambda x: (int(x)+1)/2, lis_p[best_i:best_i+K])))
print(res)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K=map(int, input().split())
Q=list(map(int, input().split()))
P=np.array([Q[i:i+K] for i in range(N-K+1)])

best=(P.sum(axis=1)).max()

"""
best=0

for i in range(N-K+1):
  point=P[i:i+K].sum()
  
  if point>best:
    best=point
"""  
    


print(best/2+K/2)

Submission status: Time Limit Exceeded

Solution code:
def cal(a):
    cal_sum = 0
    for i in range(1, a + 1):
        cal_sum += i
    return (cal_sum / a)

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

for i in range(0, N):
    p[i] = cal(p[i])

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


print(max(ans_raw))

Submission status: Time Limit Exceeded

Solution code:
N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  expected_list.append((int(p[i])+1)/2)
  
for i in range(N):
  anan = 0
  for j in range(K):
    try:
      anan += expected_list[i+j]
    except:
      pass
  max_list.append(anan)
  
print(max(max_list))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(int, input().split(' ')))
    max_p_sum = 0
    sum_list = list()
    for n in range(0, N - K + 1, 1):
        hash_sum = sum(p_list[n: n + K])
        if max_p_sum < hash_sum:
            max_p_sum = hash_sum
            sum_list = p_list[n: n + K]
    expected_value = [(1 + s) / 2 for s in sum_list]
    print(sum(expected_value))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

# １からNまでの値をもつサイコロを振ったときの期待値
def ex(x:int):
    return (x*(x+1)/2)/x

kitaichi = []
kitaichi_goukei = []
for i in range(len(p)):
    kitaichi.append(ex(p[i]))
    if i+1 >= k:
        kitaichi_goukei.append(sum(kitaichi[i+1-k:i+1]))
print (max(kitaichi_goukei))

Submission status: Time Limit Exceeded

Solution code:
def sgm(i):
    sum=0
    for j in range(i+1):
        sum+=j
    return sum

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

e=0
for i in range(idx,idx+k):
    e+=(sgm(p[i])/p[i])
print(e)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
def main():
    N,K = list(map(int, input().split()))
    p = list(map(int, input().split()))
    n = N-K+1
    kitai = [None] * n
    for i in range(N-K+1):
        kitai[i] = ((sum((p[i:i+K]))+K)*0.5)
    print('{:.12f}'.format(max(kitai)))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

P_extracted = [0]
for i in range(0, (n-k)+1):
    tmp = P[i:i+k]
    # print(tmp)
    if sum(P_extracted) < sum(tmp):
        P_extracted = tmp

# print(s_max, P_max)
e = 0
for i in P_extracted:
    # tmp = 0
    e += sum(range(1, i+1)) / i
    # print(tmp)
    # e += tmp
print(e)