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()))
exp, max_exp = 0, 0
def calc_exp(p):
  # calculate expectation
  dice = []
  for a in range(p):
    dice.append(a + 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:
def main():
    hoge = list(map(int, input().split()))
    huga = list(map(int, input().split()))
    suma = 0
    ima = 0
    for i,h in enumerate(huga):
        if i+hoge[1] <= hoge[0]:
            if suma < sum(huga[i:i+hoge[1]]):
                suma = sum(huga[i:i+hoge[1]])
                ima = i
    inter_list = huga[ima:ima+hoge[1]]
    result = 0
    for i,h in enumerate(inter_list):
        result = result + sum(list(range(1,inter_list[i]+1)))/inter_list[i]
    print(result)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
pl = list(map(int, input().split()))
pl_i = []
pl_max = 0
s = 0
for i in range(n):
    for j in range(1, pl[i]+1):
        s += j
    pl_i.append(s / pl[i])
    s = 0
for m in range(n - k + 1):
    pl_max = max(pl_max, sum(pl_i[m:m + k]))
print(pl_max)

Submission status: Time Limit Exceeded

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

max_e=0
for i in range(N-(K-1)):
  v=p[i:K+i]
  smin=len(v)
  smax=sum(v)
  kou=smax-(smin-1)
  e=(smin+smax)/2

  if max_e<e:
    max_e=e
    
print(max_e)

Submission status: Time Limit Exceeded

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

array = []
index = 0

for i in range(len(P)-K+1):
    s = sum(P[i:i+K])
    if s >= index:
        index = s
        array = P[i:i+K]


ans = 0
for i in range(K):
    s = array[i]*(array[i]+1)/2
    ans += s / array[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def expe(x):
  a = 1.0
  for i in range(1, x, 1):
    a += i / x
  return a

n, k = map(int, input().split())
li = [expe(int(j)) 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:
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 = sum(list(range(p[pos+i] + 1)))
  kitaichi = kitaichi + float(temp/p[pos+i])
  
print('{:.12f}'.format(kitaichi))

Submission status: Time Limit Exceeded

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

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

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

c = n - k + 1
exp = [0] * c

for i in range(c):
    l = p[i:(i+k)]
    for j in l:
        tmp = j * (j + 1) / 2
        exp[i] += tmp/j

print(max(exp))

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 = []
    for i in range(0, len(l)):
        r.append(l[i] / (i+1))

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

    ans = 0
    for i in A[memo:M+memo]:
        ans += r[i-1]

    return ans

print(solve())

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 = 0
		for k in range(List[i + j] + 1):
			sum = sum + k
		sum = sum / List[i + j]
		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().split())
p = list(map(int,input().split()))

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

ans_ex = 0
for i in range(K):
	ans_ex += sum(range(1,ans_list[i]+1))/ans_list[i]
print(ans_ex)

Submission status: Time Limit Exceeded

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

A=[]
base=0
B=[]

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

print(max(B))

Submission status: Time Limit Exceeded

Solution code:
A = [int(a) for a in input().split()]
N = A[0]
K = A[1]

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

raw_max = 0
maxnum = 0

for i in range(N-K+1):
    tmp = sum(P[i:i+K])
    if(raw_max < tmp):
        raw_max = tmp
        maxnum = i

ev_max = [(n+1)/2 for n in P[maxnum:maxnum+K]]

print(sum(ev_max))

Submission status: Time Limit Exceeded

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

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

maxval = 0


def expectedval(inp):
	return (1 + inp) * (inp/2) / inp

maxcomb = []
maxsum = 0
bestpos = 0

for i in range(n-(k-1)):
	summ = 0
	for j in range (k):
		summ += plist[i + j]
	if summ > maxsum:
		maxsum = summ
		bestpos = i

res = 0
for j in range (k):
	res += expectedval(plist[bestpos + j])

print(res)

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(up_to):
    sum_ex = 0.0
    for j in range(i,i+k):
        #print(p_n[j])
        sum_ex += (1 + int(p_n[j]))/2
    
    #print(sum_ex)
    if(result < sum_ex):
        result = sum_ex


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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = [int(s) for s in input().split()]

r = 0
for i in range(N - K + 1):
    r = max(r,sum(p[i:i+K]))
    
print("{:.12f}".format((r+K) /2))

Submission status: Time Limit Exceeded

Solution code:
def K(n):
    s = 0
    for i in range(1, n+1):
        s += i
    return s / i

def d():
    n, k = input().split()
    n = int(n)
    k = int(k)
    p = input().split()

    m = 0
    for i in range(0, len(p)-k+1):
        a = 0
        for i2 in range(k):
            a += int(p[i+i2])
        if m < a:
            m = a
            I = i
    m2 = 0
    for i in range(k):
        m2 += K(int(p[I + i]))
    return m2
print(d())

Submission status: Time Limit Exceeded

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

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):
    for j in range(i,i+B):
        kari=kari+x[j]
    if wa<kari:
        wa=kari
        basyo=i
    kari=0

for i in range(basyo,basyo+B):

    kotae=kotae+0.5*(x[i]+1)
print(kotae)

Submission status: Time Limit Exceeded

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

def e(n):
    e=0
    for i in range(1,n+1):
        e+=i*(1/n)
    return e
 
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:
N, K = map(int, input().split())
p = list(map(int,input().split()))

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


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

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

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

result = 0
for i in range(K):
    result += kitaichi(tmp_pair[i])
    
print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, k = (int(x) for x in input().split())
p = np.array([int(x) for x in input().split()])

max_val = 0
for i in range(0, p.shape[0]-k+1):
  tmp = p[i:i+k]
  val = sum([sum([x for x in range(1, t+1)]) / t for t in tmp])
  
  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

zeros = [0] * nk[1]

seq4search = zeros + p

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
maxsumP = -1
resP = []
for i in range(N-K+1):
  PP = P[i:K+i]
  mp = sum(PP)
  if maxsumP < mp:
    resP = PP
    maxsumP = mp
res = 0
for p in resP:
  res += sum(range(p+1))/float(p)
    
print(res)

Submission status: Time Limit Exceeded

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

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

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

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

    return

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

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

    return

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

k = [0]*N

def kitaiti(n):
    sum = 0
    for i in range(1,n+1):
        sum += i
    return sum / n
"""    
for i in range(N):
    k[i] = kitaiti(p[i])
"""
ans = 0
index = 0
for i in range(N-K+1):
#    ans = max(ans,sum(p[i:i+K]))
    if ans < sum(p[i:i+K]):
        ans = sum(p[i:i+K])
        index = i

ans = 0
for i in range(K):
    ans += kitaiti(p[index + i])
print(ans)

Submission status: Time Limit Exceeded

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

[N, K] = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

sum_list = []
for i in range(len(P)-(K-1)):
    sum_list.append(sum(P[i: i+K]))

#print(sum_list)
max_index = sum_list.index(max(sum_list))
#print(max_index)

# 隣接したK個のリスト
kk = P[max_index: max_index+K]

# kの期待値を計算
max_kk = max(kk)
dp = [0]
for i in range(1, max_kk+1):
    dp.append(dp[i-1] + i)
#print(dp)

ans = 0
for k in kk:
    ans += dp[k]/k

print(ans)

Submission status: Time Limit Exceeded

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

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

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

Submission status: Time Limit Exceeded

Solution code:
def calc_exp(n):
    s = sum(list(range(1,n+1)))
    return s/n

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

ans_cand = []

for i in range(N-K+1):
    tmp_sum = 0
    for j in range(K):
        tmp_sum += calc_exp(P[i+j])
    ans_cand.append(tmp_sum)

print(max(ans_cand))

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

ans = 0
for j in range(ansi ,ansi + k ):
  ans += (p[j] + 1 ) / 2

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(0, N):
  if i+K > N:
    break

  if i == 0:
    max_sum = sum(p_list[0:K])+K
  else:
    tmp = sum(p_list[i:i+K])+K
    if max_sum < tmp:
      max_sum = tmp

print(max_sum/2)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
arr = list(map(int, input().split()))
big = 0
kitai = 0
for i in range(n-k+1):
    kitai = 0
    for j in range(i,i+k):
        kitai = kitai + (arr[j]+1)/2
    if big < kitai:
        big = kitai
print(big)

Submission status: Time Limit Exceeded

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

li = [0] * (N - K + 1)
dict = {}

#一番大きな数を含む並び順を求める
for i in range(N - K + 1):
    for j in range(K):
        #期待値を計算してなかったら、計算
        if(dict.get(P[i + j], -1) == -1):
            tmp = 0
            p = P[i + j]
            for k in range(1, p + 1):
                tmp = tmp + (k / p)
            dict[p] = tmp

        li[i] = li[i] + dict.get(P[i + j])


print(max(li))

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())))
 
max_value=0
for i in range(N-K+1):
    if max_value < sum(P[i:i+K]):
        max_value = sum(P[i:i+K])
        max_i = i
max_vector = P[max_i:max_i+K]
 
sum_ex = 0
for i in range(K):
    sum_ex = sum_ex + sum(np.arange(max_vector[i]+1)) / max_vector[i]
print(sum_ex)

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

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

Submission status: Time Limit Exceeded

Solution code:
def tasu(x):
    ans = 0
    for i in range(1 , x + 1):
        ans += i
    return ans

def kitaiti(n , k , p):

    ans = 0
    kitai = [0]*n
    #tf = [False]*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 = list(map(int, input().split()))
P = list(map(int, input().split()))

tmp = [sum(list(range(1,i+1)))/i for i in P]

res = 0.0
for k in list(range(N)):
    choise = tmp[k:K+k]
    if len(choise) == K:
        if res < sum(choise):
            res = sum(choise)

print(res)

Submission status: Time Limit Exceeded

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

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

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

print(A)

Submission status: Time Limit Exceeded

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

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

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())
p = tuple(map(int, input().split()))
ans = []
f = N-K+1
for i in range(f):
    ans.append(sum(p[i : i + K]))
print((max(ans) + K) / 2)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
#最大のリストを選定
before_pi = 0
for i in range(0,n-k+1):
    if before_pi > p[i+k-1]:
        before_pi = p[i]
        continue
    ck = sum(p[i:i+k])
    if ck > max:
        max = ck

#計算
print((max+k)/2.0)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    sump = 0
    ind = 0
    for i in range(n-k+1):
        for j in range(i, i+k):
            if sump < sum(p[i:i+k]):
                sump = sum(p[i:i+k])
                ind = i
    e = 0
    for i in range(ind, ind+k):
       e += (p[i]+1) / 2 
    print(e)
    
main()

Submission status: Time Limit Exceeded

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


def solve(N: int, K: int, p: "List[int]"):
    max_value = 0
    for i in range(N - K + 1):
        compare_value = sum([p[i + k] for k in range(K)])

        if max_value < compare_value:
            max_value = max(max_value, compare_value)
            index_first = i
        else:
            pass
    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        result += sum(
            [i / p[index_first + j] for i in range(1, p[index_first + j] + 1)]
        )
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

e = [(pi+1)/2 for pi in p]

ret = []
for i in range(n-(k-1)):
        b = 0.0
        for j in range(k):
                b += e[i+j]
        ret.append(b)

ret.sort()
print(ret[n-k])

Submission status: Time Limit Exceeded

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

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

list00 = []
for i in range(0, n):
  list00.append(one_n_sum(p[i])/p[i])

def larger(x,y):
  if x>=y:
    return x
  else:
    return y

m = 0
for j in range(0, n-k+1):
  m_cal = sum(list00[j:j+k])
  m = larger(m,m_cal)
  
print(m)

Submission status: Time Limit Exceeded

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

input_line = [int(i) for i in input().split(" ")]

excepted_value = []
for i in input_line:
    excepted_value.append(sum(range(i+1)) / i)

max_excepted_value = 0
for i in range(len(input_line) - k + 1):
    sum_excepted_value = sum(excepted_value[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:
from collections import deque

n, k = map(int, input().split())
l = deque(list(map(int, input().split())))
d = deque()

for _ in range(k):
  d.append(l.popleft())
now = sum(d)  
for i in range(n-k):
  d.popleft()
  d.append(l.popleft())
  now = max(sum(d), now)
  
print((now + k) / 2)

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-k+1):
    # print(i,tmp,p[i:i+k])
    if sum(p[i:i+k])>tmp:
        # print(i,tmp)
        tmp = sum(p[i:i+k])
        ans= i
anss=0
for j in p[ans:ans+k]:
    anss+=(j+1)/2


print(anss)

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(N-K+1):
  DP[i] = sum(P[i:i+K])

max_index = DP.index(max(DP))

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

Submission status: Time Limit Exceeded

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

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

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

max_p = p[point:point+k]
kitai = [expected_value(i) for i in max_p]
print(sum(kitai))

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))
    maxi = ps[:K]
    expected = ps[:K]
    for index in range(K, N):
        expected.pop(0)
        expected.append(ps[index])
        if sum(expected) > sum(maxi):
            maxi = expected[:]
    res = sum([(x + 1) / 2 for x in maxi])
    print(res)

solve()

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 += upper / item

  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:
def expe(x):
  l = [i/x for i in range(1, x, 1)] + [1.0]
  return sum(l)

n, k = map(int, input().split())
li = [expe(int(j)) 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
N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

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

i = np.argmax(ppp)

tmp = p[i:i+K]
print(np.sum(tmp+1)*0.5)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    tmp = input().replace('\n','').split()
    p = input().replace('\n','').split()
    p = [int(p) for p in p]
    max=0
    for k in range(len(p)-int(tmp[1])+1):
        res=0
        for i in range(int(tmp[1])):
            tmp1=0
            for j in range(int(p[k+i])+1):
                tmp1 += j
            res += tmp1/p[k+i]
        if max < res:
            max = res
    print(max)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Time Limit Exceeded

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

    sums = [0] * (n-k+1)
    i = 0
    while i < k:
        if k-i > 1:
            sums += p[i:(k-i-1) * -1]
            i += 1
        else:
            sums += p[i:]
            i += 1

    print((np.max(sums) + k) / 2)

resolve()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
num = np.array(p)
max_i = 0

for i in range(n-k+1):
    sum_i = 0
    sum_i = np.sum(num[i:i+k])
    
    if max_i < sum_i:
        max_i = sum_i

print((max_i+k)/2)

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 * (int(v) -1)

_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:
def calc(A):
    res = 0
    res = (1+A)/2
    return res
    
N, K = map(int, input().split())
P = list(map(int, input().split()))
res = 0
for i in range(N-K+1):
    part = 0
    part = sum(P[i:i+K])
    if res < part:
        res = part
        ans = 0
        for j in range(K):
            ans += calc(P[i+j])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
val_num = N - K + 1
max_sum = 0
for i in range(val_num):
    val = sum(p_list[i:i+K])
    if val > max_sum:
        max_sum = val

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

Submission status: Time Limit Exceeded

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


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

kitaichi = k/2 + sum(p_list[index:index+k])/2
    
print(kitaichi)

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()
p = read_int()

def solve():
    res = 0
    index = 0
    for h in range(N - K + 1):
        partial = 0
        for i in range(h, h + K):
            partial += p[i]
        if res < partial:
            index = h
            res = partial
    ans = 0
    for i in range(K):
        ans += (p[index + i] + 1) / 2
    return ans

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map( int, input().split())
    P = list(input().split())
    expected = []
    for i,p in enumerate(P):
        ex = float(1/float(p))*float(float(p)*(float(p)+1)/2)
        expected.append(ex)
    
    max_ex = 0
    for i in range(N-K+1):
        sum_ex = sum(expected[i:i+K])
        if sum_ex>max_ex:
            max_ex = sum_ex

    print(max_ex)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split()) 
p = list(map(float, input().split()))
n_e = n - k + 1
e = [0] * n_e
for i in range(n_e):
  temp = sum(p[i:i+k])
  temp = (temp + k) * 0.5
  e[i] = temp
ans = "{0:.10f}".format(max(e))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
a = np.array(a)

Max = 0

for i in range(n-d+1):
  Sum = a[i:i+d].sum()
 
  if Sum >= Max:
    Max = Sum
    ans = a[i:i+d]    
  else:
    pass
  
ans = ans*0.5 + 0.5
print(ans.sum())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    strings = input().split(' ')
    N = int(strings[0])
    K = int(strings[1])
    p_raw = input().split(' ')
    exp = []
    for i in p_raw:
        exp.append((int(i)+1)/2.)
    max = 0
    for i in range(N-K+1):
        
        sum_exp = sum(exp[i:i+K])
        if sum_exp > max:
            max = sum_exp
            
    
    print(max)
    return 0

main()

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p_ = {}
for i in set(p):
  p_[i] = sum(range(i+1))/i

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