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()))
p = list(map(lambda x:(x+1)/2,p))
from itertools import accumulate
A =  [0] + list(accumulate(p))
M = 0
index = 0
for x in range(N - K +  1):
    M = max(M,sum(p[x: x  + K]))
print(M)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
N = a[0]
K = a[1]
P = list(map(int, input().split()))

# for i in range(len(P)):
#     P[i] = (float)(P[i]+1)/2

max = 0
maxj = 0

for i in range(len(P)-K+1):
    num = 0
    for j in range(K):
        num += P[i+j]
        # print(P[i+j],end=" ")
    # print(num)
    if(max < num):
        max = num
        maxj = i

a = 0
for i in range(K):
    a += (float)(P[maxj+i]+1)/2

print("{0:6f}".format(a))

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
N = a[0]
K = a[1]
P = list(map(int, input().split()))

for i in range(len(P)):
    P[i] = (float)(P[i]+1)/2

max = 0

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

    if(max < num):
        max = num

print("{0:6f}".format(max))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
p = list(map(int, input().split()))
tmpnum, maxnum, tmparr, maxarr = 0, 0, [], []
ex = 0


for i in range(N-K+1):
    tmparr = p[N-K-i:]
    tmp = sum(tmparr) / K
    if maxnum < tmp:
        maxnum = tmp
        maxarr = tmparr
    p.pop()

for j in range(K):
    ex +=  (1 + maxarr[j]) / 2
print(ex)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
p = list(map(int, input().split()))
tmpnum, maxnum, tmparr, maxarr = 0, 0, [], []
dice, ex = [], 0


for i in range(N-K+1):
    tmparr = p[N-K-i:]
    tmp = sum(tmparr) / K
    if maxnum < tmp:
        maxnum = tmp
        maxarr = tmparr
    p.pop()

for j in range(K):
    dice = [_ + 1 for _ in range(maxarr[j])]
    ex +=  (1 + dice[-1]) / 2
print(ex)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,k=map(int,input().split())
P=list(map(int,input().split()))

s=[(1/2)*x*(x+1)/x for x in P]
print(max([sum(s[f:f+k]) for f in range(len(P)-k+1)]))

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:
def expected(n):
  return n/2 + 0.5

n, k = map(int, input().split())
nums = list(map(lambda x: expected(int(x)), input().split()))

highest = 0
for i in range(n):
  if i + k -1 > n -1 : break
  
  score = 0
  for ii in range(k):
    score += nums[i + ii]
    
  if score > highest: highest = score
print(highest)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
p = list(map(int, input().split()))
tmpnum, maxnum, tmparr, maxarr = 0, 0, [], []
dice, ex = [], 0


for i in range(N-K+1):
    tmparr = p[N-K-i:]
    tmp = sum(tmparr) / K
    if maxnum < tmp:
        maxnum = tmp
        maxarr = tmparr
    p.pop()

for j in range(K):
    dice = [_ + 1 for _ in range(maxarr[j])]
    ex += sum(dice) / len(dice)
print(ex)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,k=map(int,input().split())
P=list(map(int,input().split()))


s=[(1/2)*x*(x+1)/x for x in P]
number=len(P)-k+1
sum_=[sum(s[f:f+k]) for f in range(number)]
    
print(max(sum_))

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,k=map(int,input().split())
P=list(map(int,input().split()))

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

s=[cumsum_(x)/x for x in P]
number=len(P)-k+1
sum_=[sum(s[f:f+k]) for f in range(number)]
    
print(max(sum_))

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,k=map(int,input().split())
P=list(map(int,input().split()))

s=[sum(range(1,x+1,1))/(x) for x in P]
number=len(P)-k+1
sum_=[sum(s[f:f+k]) for f in range(number)]
    
print(max(sum_))

Submission status: Time Limit Exceeded

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

s=[np.mean(range(1,x+1,1)) for x in P]
number=len(P)-k+1
sum_=[sum(s[f:f+k]) for f in range(number)]
    
print(max(sum_))

Submission status: Time Limit Exceeded

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

s=[np.mean(range(1,x+1,1)) for x in P]
    
sum_=[]
number=len(P)-k+1
for f in range(number):
    sum_.append(sum(s[f:f+k]))
    
print(max(sum_))

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
n,k=map(int,input().split())
P=list(map(int,input().split()))

s=[]
for p in P:
    ps=range(1,p+1,1)
    a=0
    for pss in ps:
        a+=pss
    s.append(a/len(ps))

sum_=[]
number=len(P)-k+1
for f in range(number):
    sum_.append(sum(s[f:f+k]))
    
print(max(sum_))

Submission status: Time Limit Exceeded

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

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  if i == 0:
    R.append(sum(Q[i:i+K]))
  else:
    R.append(sum(Q[:i+K])-sum(Q[:i]))

print(max(R))

Submission status: Time Limit Exceeded

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

calRes = 0
calIndex = 0
expectedList = []

for i in range(N):
    cal = list(range(1, p[i] + 1))
    expectedList.append(sum(cal) * (1 / len(cal)))

for o in range(N - (K - 1)):
    calTemp = sum(expectedList[o:o + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = o

expectedCorrect = sum(expectedList[calIndex : calIndex + K])

print(expectedCorrect)

Submission status: Time Limit Exceeded

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

calRes = 0
calIndex = 0
expectedList = []
expectedCorList = []
Counter = 0

for i in range(N):
    cal = list(range(1, p[i] + 1))
    Counter += 1
    expectedList.append(sum(cal) * (1 / len(cal)))

for o in range(N - 2):
    calTemp = sum(expectedList[o:o + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = o

for l in range(K):
    expectedCorList.append(expectedList[calIndex + l])

calCor = sum(expectedCorList)
print(calCor)

Submission status: Time Limit Exceeded

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

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  R.append(sum(Q[i:i+K]))

print(max(R))

Submission status: Time Limit Exceeded

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

def kitai(p):
  return (p+1)/2

for i in range(N):
  Q.append(kitai(P[i]))

for i in range(N - K + 1):
  if i == 0:
    R.append(sum(Q[i:i+K]))
  else:
    R.append(sum(Q[i:i+K]))

print(max(R))

Submission status: Time Limit Exceeded

Solution code:
import sys
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
R = []
r = 0
if not 1 <= K <= N <= 2*10**5:
    sys.exit()
for i in range(N):
    q = (1 + P[i]) / 2
    Q.append(q)
for j in range(N-K+1):
    r_max = sum(Q[j:j+K])
    if r <= r_max:
        r = r_max
print(r)

Submission status: Time Limit Exceeded

Solution code:

def get_expected_value(n):

    # expected_value = 0
    # for i in range(1,n+1):
    #     expected_value += i / n
    # return expected_value
    return (1 + n) / 2

def main():
    n, k = map(int,input().split())
    pn = list(map(int,input().split()))
    expected_value_sum_max = 0
    for i in range(n-k+1):
        tmp = 0
        for j in range(k):
            tmp += get_expected_value(pn[i+j])

        if tmp > expected_value_sum_max:
            expected_value_sum_max = tmp

    print(expected_value_sum_max)

if __name__ == '__main__':
  	main()

Submission status: Time Limit Exceeded

Solution code:

def get_expected_value(n):

    expected_value = 0
    for i in range(1,n+1):
        expected_value += i / n
    return expected_value

def main():
    n, k = map(int,input().split())
    pn = list(map(int,input().split()))
    expected_value_sum_max = 0
    for i in range(n-k+1):
        tmp = 0
        for j in range(k):
            tmp += get_expected_value(pn[i+j])

        if tmp > expected_value_sum_max:
            expected_value_sum_max = tmp

    print(expected_value_sum_max)

if __name__ == '__main__':
  	main()

'''
5 3
1 2 2 4 5
'''

Submission status: Time Limit Exceeded

Solution code:
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = []
R = []
r = 0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    q = (1 + P[i]) / 2
    Q.append(q)
    
for j in range(N-K+1):
    r = sum(Q[j:j+K])
    R.append(r)
print(max(R))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
P = list(map(int, input().split()))
 
A = 0
for i in range(N-K+1):
  B = 0
  for j in range(K):
    B += (1 + P[i+j])/2
    if B > A:
      A = B
 
print(A)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split(' ')))
p_list = list(map(int, input().split(' ')))
max_val = 0
for i in range(N - K + 1):
    E_sum = 0
    for j in range(K):
        index = i + j
        E_sum += p_list[index]
    E_sum = (E_sum + K) / 2.0
    if max_val < E_sum:
        max_val = E_sum
print(max_val)

Submission status: Time Limit Exceeded

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

K = A[1]
N = A[0]

P = list(map(float, input().split()))

new_list = []

for val in range(N-K+1):
    P_list=P[val:val+K]
    new_list.append(sum(list(map(lambda x: (1+x) / 2, P_list))))

print(max(new_list))

Submission status: Time Limit Exceeded

Solution code:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

cemsum = [0]*(Input1[0]-Input1[1]+1)

for j in range(0,Input1[0]-Input1[1]+1):
    cemsum[j] = sum(Input2[j:j+Input1[1]])

print(max(cemsum))

Submission status: Time Limit Exceeded

Solution code:
import sys

I = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
N = I[0] # サイコロ数
K = I[1]
Q = []
R = []
r = 0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    q = sum(range(1, P[i]+1)) / P[i]
    Q.append(q)
    for j in range(N-K+1):
        r = sum(Q[j:j+K])
        R.append(r)
print(max(R))

Submission status: Time Limit Exceeded

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

for nn in range(n-k+1):
    kai.append(sum(sai[nn:nn+k]))

print(max(kai))

Submission status: Time Limit Exceeded

Solution code:
import sys

I = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
N = I[0] # サイコロ数
K = I[1]
if not 1 <= K <= N <= 2*10**5:
    sys.exit()

Q = []
for i in range(N):
    q = sum(range(1, P[i]+1)) / P[i]
    Q.append(q)
# print(Q)

r = 0
R = []
for i in range(N-K+1):
    r = sum(Q[i:i+K])
    R.append(r)
# print(R)
print(max(R))
# rangeの終端は+1

Submission status: Time Limit Exceeded

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

lists_of_p_list = [p_list[i:] for i in range(K)]
sum_list = [sum(x) for x in zip(*lists_of_p_list)]
print((max(sum_list)+ K)/ 2)

Submission status: Time Limit Exceeded

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

m = -1
index = -1
for i in range(n-k+1):
    tmp = sum(p[i:i+k])
    if tmp > m:
        m = tmp
        index = i


def calc_exp(p):
    return ((p * (p+1)) / 2) / p
        
exp = 0
for i in range(index,index+k):
    exp += calc_exp(p[i])

print(exp)

Submission status: Time Limit Exceeded

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

m = -1
index = -1
for i in range(n-k+1):
    tmp = sum(p[i:i+k])
    if tmp > m:
        m = tmp
        index = i


def calc_exp(p):
    num = list(range(1,p+1))
    return sum(num) / p
        
exp = 0
for i in range(index,index+k):
    exp += calc_exp(p[i])

print(exp)

Submission status: Time Limit Exceeded

Solution code:
# それぞれの期待値の計算
# a: (1/2 * a * (a+1)) / a => 1/2 * (a+1)
# b: (1/2 * b * (b+1)) / b => 1/2 * (b+1)
# c: (1/2 * c * (c+1)) / c => 1/2 * (c+1)
# 期待値の合計
# 1/2 * (a+b+c+3)


N, K = map(int,input().split())
p_list = [int(x) for x in input().split()]

max_exp = .0
for i in range(len(p_list)+1-K):
    exp = sum(p_list[i:i+K])
    if exp > max_exp:
        max_exp = exp
print((max_exp+ K)/ 2)

Submission status: Time Limit Exceeded

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

m = -1
index = -1
for i in range(n-k+1):
    tmp = sum(p[i:i+k])
    if tmp > m:
        m = tmp
        index = i


def calc_exp(p):
    e = 0
    for i in range(1,p+1):
        e += i/p
    return e
        
exp = 0
for i in range(index,index+k):
    exp += calc_exp(p[i])

print(exp)

Submission status: Time Limit Exceeded

Solution code:
def kitaiti(number):
    count = 0
    for i in range(1,number + 1):
        count += (i / number)
    return count
def dp(mylist,K,N):
    i = 0
    count = sum(mylist[i:K + i])
    while K + i < N:
        i += 1
        if count < sum(mylist[i:K + i]):
            count = sum(mylist[i:K + i])
    return count
N,K = (int(i) for i in input().split())
p = [int(x) for x in input().split()]

kitaiti = [kitaiti(x) for x in p]

print(dp(kitaiti,K,N))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P_ = [int(x) for x in input().split()]
P=[None]*N #空リストには何かしらの値を入れておく。

def kitai(n):
    s=(n+1)/2
    return s

def wa(N,K,P):
    list = [0]*(N-K+1)
    for i in range(N-K+1):
        list[i]=sum(P[i:i+K])
    return list

for i in range(N):
    P[i]=kitai(P_[i])

print(max(wa(N,K,P)))

Submission status: Time Limit Exceeded

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

max_dice_list = []
for i in range(len(p_list)+1-K):
    if sum(p_list[i:i+K]) > sum(max_dice_list):
        max_dice_list = p_list[i:i+K]

sum_exp = .0
for dice in max_dice_list:
    sum_exp += sum(range(1, dice+1))/dice

print(sum_exp)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P_ = [int(x) for x in input().split()]
P=[None]*N #空リストには何かしらの値を入れておく。

def kitai(n):
    s=sum(range(n+1))/n
    return s

def wa(N,K,P):
    list = [0]*(N-K+1)
    for i in range(N-K+1):
        list[i]=sum(P[i:i+K])
    return list

for i in range(N):
    P[i]=kitai(P_[i])

print(max(wa(N,K,P)))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
P_ = list(map(int,input().split()))
P=[None]*N #空リストには何かしらの値を入れておく。

def kitai(n):
    s=sum(range(n+1))/n
    return s

def wa(N,K,P):
    list = [0]*(N-K+1)
    for i in range(N-K+1):
        list[i]=sum(P[i:i+K])
    return list

for i in range(N):
    P[i]=kitai(P_[i])

print(max(wa(N,K,P)))

Submission status: Time Limit Exceeded

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

# N, K = 5, 3
# p_list=[1,2,2,4,5]


# N, K = 4, 1
# p_list=[6,6,6,6]

# N, K =10, 4
# p_list=[17,13,13,12,15,20,10,13,17,11]

def pick_high_exp_dices(l, num):
    max_dice_list = []
    for i in range(len(l)+1-num):
        if sum(l[i:i+num]) > sum(max_dice_list):
            max_dice_list = l[i:i+num]
    return max_dice_list

def calc_exp(max_num):
    return sum(range(1, max_num+1))/max_num

good_dices = pick_high_exp_dices(p_list, K)

sum_exp = .0
for dice in good_dices:
    sum_exp += calc_exp(dice)

print(sum_exp)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

MAX_P = 1000

p = np.array(tmp_p, dtype=np.int64)
#total_value = np.zeros(MAX_P, dtype=np.int64)
expect_value = np.zeros(N)

# total_value[0] = 1
# for i in range(1, MAX_P):
#    total_value[i] = total_value[i-1] + i + 1

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

max_value = 0.0
for i in range(N-K+1):
    tmp_value = sum(expect_value[i:i+K])
    if max_value < tmp_value:
        max_value = tmp_value

print(max_value)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

MAX_P = 1000

p = np.array(tmp_p, dtype=np.int64)
#total_value = np.zeros(MAX_P, dtype=np.int64)
expect_value = np.zeros(N)

# total_value[0] = 1
# for i in range(1, MAX_P):
#    total_value[i] = total_value[i-1] + i + 1

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

max_value = 0.0
for i in range(N-K+1):
    tmp_value = sum(expect_value[i:i+K])
    if max_value < tmp_value:
        max_value = tmp_value

print(max_value)

Submission status: Time Limit Exceeded

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

kitai = []
ans = []
for i in range(n):
    kitai.append((p[i] + 1) / 2)

for i in range(n - k + 1):
    ans.append(sum(kitai[i:i + k]))
print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def kitaiti(a):
    prob=1/a
    b=0
    for i in range(1,a+1):
        b+=i
    kitaiti=prob*b
    return kitaiti

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

e=0
anse=0
for i in range(N-K+1):
    e=0
    for j in range(i,i+K):
        e+=kitaiti(p[j])
    if anse<e:
        anse=e
    else:
        pass

print(anse)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
sai = list(map(int,input().split()))
kk = []
for x in range(len(sai)):
    sai[x] = ((sai[x]+1)*sai[x])/2/sai[x]
for y in range(n-k+1):
    kk.append(sum(sai[y:y+k]))
print(max(kk))

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 (k+1)/2
 
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 = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * n

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

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

Submission status: Time Limit Exceeded

Solution code:
def main(N,K,p):
    summary = []
    sumi = 0
    for i in range(len(p)-K+1):
        for j in range(K):
            sumi += p[i+j]
        summary.append(sumi)
        sumi = 0
    return (max(summary) + K) / 2

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

Submission status: Time Limit Exceeded

Solution code:
def main(N,K,p):
    summary = 0
    sumi = 0
    for i in range(len(p)-K+1):
        for j in range(K):
            sumi += p[i+j]
        summary = max(summary,sumi)
        sumi = 0
    return (summary + K) / 2 

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

Submission status: Time Limit Exceeded

Solution code:
def exp(n):
  return sum(range(n + 1)) / n

N, K = map(int, input().split())
p = list(map(int, input().split()))
a = [0.0]
for i in range(N):
  a.append(a[i] + exp(p[i]))
m = 0
for i in range(N - K + 1):
  m = max(m, a[i + K] - a[i])
print(m)

Submission status: Time Limit Exceeded

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

cad_sum = 0
cad_sum_ori = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]

    if sum(cad_p_list) < cad_sum_ori:
        continue

    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = (cad_p+1)/2
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child
        cad_sum_ori = sum(cad_p_list)
        
print(cad_sum)

Submission status: Time Limit Exceeded

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

cad_sum = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]
    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = (cad_p+1)/2
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child

print(cad_sum)

Submission status: Time Limit Exceeded

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

cad_sum = 0
for i in range(n-k+1):
    cad_p_list = p_list[i:i+k]
    cad_sum_child_list = []
    for cad_p in cad_p_list:
        cad_sum_child = 0
        for num in range(1, cad_p+1):
            cad_sum_child += num
        cad_sum_child /= cad_p
        cad_sum_child_list.append(cad_sum_child)

    cad_sum_child = sum(cad_sum_child_list)
    if  cad_sum_child > cad_sum:
        cad_sum = cad_sum_child

print(cad_sum)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(x) for x in input().split()]
p = [int(x)+1 for x in input().split()]
t=0
for i in range(N-K+1):
  g=sum(p[i:i+K])
  if t<g:
    t=g
print(t/2)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [sum(range(int(x)+1))/int(x) for x in stdin.readline().rstrip().split()]
l = 0
r = len(P)
m = 0
while(K <= r):
    kitai = sum(P[l:K])
    if (kitai > m):
        m = kitai
    l +=1
    K +=1

print(m)

Submission status: Time Limit Exceeded

Solution code:
# 

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

ans=[]

for i in p:
    ex.append((1+i)/2)

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

slist = [sum(P[i:i+K]) for i in range(N-K+1)]
max_idx = np.argmax(slist)

exp = 0
for v in P[max_idx:max_idx+K]:
    exp += sum(np.arange(1, v+1)) / v

print(exp)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
list_p = [int(x) for x in input().split()]

max = 0

for i in range(0,N-K+1) :
    total = sum(list_p[i:i+K])
    if total > max :
        max = total

print((max+K)/2)

Submission status: Time Limit Exceeded

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

E = []
for i in P:
    E.append((i+1)/2)
# print(E)

sum_E = [0, ]
for i in range(N):
    sum_E.append(sum(E[0:i+1]))
# print(sum_E)

sum_K = []
ans = 0
for i in range(N-K+1):
    if sum_E[i+K] - sum_E[i] > ans:
        ans = sum_E[i+K] - sum_E[i]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

S = 0
reg = 0

for i in range(n-k+1):
    s = sum(p[i:i+k])
    if S < s:
        S = s
        reg = i
        
ans = 1 / 2 *(S + k)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import decimal

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

S = 0
reg = 0

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

P = [(list(accumulate([x for x in range(i+1)]))[-1])/i for i in p]
ans = max([sum(P[i:i+k]) for i in range(n-k+1)])

print(ans)

Submission status: Time Limit Exceeded

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

# 各サイコロの期待値を出す
expect = []
for i in range(N):
  expect.append((1 + num[i]) / 2)

# 隣接するN個の期待値を出す
max = 0
for i in range(N):
  if i > N - K:
    break
  temp = 0
  for j in range(K):
	  temp = temp + expect[i + j]
  if max < temp:
    max = temp
print(max)

Submission status: Time Limit Exceeded

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

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

for i in range(n):
    exps.append(sum(list(range(1, p[i]+1)))/p[i])

sums = []
for i in range(n-(k-1)):
    tmp = 0 
    for j in range(k):
        tmp += exps[i+j]
    sums.append(tmp)

ans = max(sums)
print(ans)

Submission status: Time Limit Exceeded

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


l = [(x+1)/2 for x in range(1,1001)]

ansSum = 0
for i in range(n-k+1):
    List = p[i:i+k]
    Sum = sum(List)
    if Sum > ansSum:
        ansSum = Sum
        ansList = List

ans = 0
for j in ansList:
    ans += l[j-1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
y = 0
for x in range(1, 1001):
    y += x
    l.append(y/x)

ansSum = 0
for i in range(n-k+1):
    List = p[i:i+k]
    Sum = sum(List)
    if Sum > ansSum:
        ansSum = Sum
        ansList = List

ans = 0
for j in ansList:
    ans += l[j-1]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def ex(p,n):
    return (p[n]+1)/2

def  sum(p,n):
    s=0
    for i in range (0,n+1):
        s=s+ex(p,i)
    return s

list=[]
for i in range (0,N):
    list.append(sum(p,i))

max=list[K-1]
for i in range (0,N-K):
   if list[i+K]-list[i] >= max:
        max=list[i+K]-list[i]
        
print(max)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
ma = {}
def _sum(n):
    if not n in ma:
        ma[n] = sum(range(1,n+1))
    return ma[n]

def ev(v):
    return _sum(v) * 1.0/v

N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]
 
m = 0
i = 0
while K+i <= N:
    v = 0
    for k in range(K):
        v += p[i+k]
    if m < v:
        m = v
    i += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
m = {}
def ev(v):
    if not v in m:
        m[v] = sum(range(1,v+1)) * 1.0/v
    return m[v]

N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]
 
m = 0
i = 0
while K+i <= N:
    v = 0
    for k in range(K):
        v += p[i+k]
    if m < v:
        m = v
    i += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
 
def ev(v):
    return sum(range(1,v+1)) * 1.0/v
 
N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]
 

cur = sum([p[i] for i in range(K)])
_max = cur

i = K-1
j = 0

while i < N - 1:
    cur -= p[j]
    i += 1
    j += 1
    cur += p[i]
    if _max < cur:
        _max = cur

print(_max)

Submission status: Time Limit Exceeded

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

def solve(N: int, K: int, p: "List[int]"):
    ans = 0.0
    max = -1
    for i in range(0,N-K+1):
        tmp = 0
        for j in range(i,i+K):
            tmp += p[j]

        if tmp > max:
            max = tmp
    ans = (max/2) + (K * 0.5)
    print(ans)

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