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

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

kl = []

for i in range(len(s)):
    kitai = (s[i] + 1) * (s[i] / 2) / s[i]
    kl.append(kitai)

mx = 0
    
while len(kl) >= k:
    
    
    d = sum(kl[0:k])
    
    if d >= mx:
        mx = d
        
    kl.pop(0)
    

print(mx)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

max_sum = 0
for i in range(N-K+1):
    max_sum = max(max_sum, np.sum(P[i:i+K]))
    
print((max_sum + K) / 2)

Submission status: Time Limit Exceeded

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

max_sum = 0
for i in range(N-K+1):
    max_sum = max(max_sum, sum(P[i:i+K]))
    
print((max_sum + K) / 2)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))
    
    s = []
    for i in range(n-k+1):
        s.append((sum(p[i:i+k])+k)/2)    
    print(max(s))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))
    
    s = []
    for i, v in enumerate(p):
        if i + k > len(p):
            break
        #print(p[i:i+k])
        s.append((sum(p[i:i+k])+1*k)/2)    
    print(max(s))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
*P, = map(int, input().split())
# expec = tuple((P[i] * (P[i] + 1) / 2) / P[i] for i in range(N))
expec = tuple((P[i] + 1) / 2 for i in range(N))
ans = 0
for i in range(N-K+1):
    a = expec[i:i+K]
    s = sum(a)
    ans = max(ans, s)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
*P, = map(int, input().split())
chk = 0
start_idx, end_idx = 0, 0
for i in range(N-K+1):
    if chk <= sum(P[i:i+K]):
        chk = sum(P[i:i+K])
        start_idx = i
        end_idx = i+K
ans = 0
for i in range(start_idx, end_idx):
    ans += (P[i] * (P[i] + 1) / 2) / P[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
*P, = map(int, input().split())
expec = tuple((P[i] * (P[i] + 1) / 2) / P[i] for i in range(N))
ans = 0
for i in range(N-K+1):
    a = expec[i:i+K]
    s = sum(a)
    ans = max(ans, s)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    lans=[]
    for i in range(n-k+1):
        if cnt<sum(l[i:i+k]):
          cnt=sum(l[i:i+k])
          lans=l[i:i+k]
    ans=0
    for j in lans:
        ans+=(0.5*j*(1+j))/j
    print(ans)
resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# i番目の期待値は(1/p_i)*(sum(1からp_iまでの和)))

def get_E(x):
    return (sum(list(range(1,x+1))))/x

E_list = [get_E(p_i) for p_i in p]


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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
for i in range(n-k+1):
#    print(ExP[i: i+k])
    ans = max(ans, sum(ExP[i: i+k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
P = list(map(int, input().split()))
ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
for i in range(n-k+k):
#     print(ExP[i: i+k])
    ans = max(ans, sum(ExP[i: i+k]))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

p_total = 0
ans = 0

for i in range(n - k +1):
    tmp = sum(p[i:i+k])
    p_total = max(p_total, tmp)

ans = (k + p_total)/2
print(ans)

Submission status: Time Limit Exceeded

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

p_total = []
max_p_total = 0
ans = 0

for i in range(n - k +1):
    p_total.append(sum(p[i:i+k]))

max_p_total = max(p_total)
ans = (k + max_p_total)/2
print(ans)

Submission status: Time Limit Exceeded

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

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


for i in range(n - k +1):
    ans.append(sum(expect_value_dice[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()))

expect_value = []

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


max_expect_value = 0
for i in range(n - k + 1):
    tmp = 0
    tmp = sum(expect_value[i:i+k])
    max_expect_value = max(tmp, max_expect_value)

print(max_expect_value)

Submission status: Time Limit Exceeded

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

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

ans = (ans + K) / 2    

print(ans)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import numpy as np

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

p = (p + 1) / 2

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

print(ans)

Submission status: Time Limit Exceeded

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

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

max_sum = 0
max_where = 0

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

    if temp_sum > max_sum:
        max_sum = temp_sum

print(max_sum)




#n,k = map(int,input().split())
#
#p = list(map(int,input().split()))
#
#max_sum = 0
#max_where = 0
#
##pi ~ pi+2の合計が最大のものが期待値も最大になる。
#for i in range(0,n-k+1):
#    temp_sum = sum(p[i:i+k])
#    if temp_sum > max_sum:
#        max_sum = temp_sum
#        max_where = i
#
#result = 0
#
#for j in range(k):
#    result += ((p[max_where + j] + 1) * p[max_where + j] / 2) / p[max_where + j]
#
#print(result)

Submission status: Time Limit Exceeded

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

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

max_sum = 0
max_where = 0

#pi ~ pi+2の合計が最大のものが期待値も最大になる。
for i in range(0,n-k+1):
    temp_sum = sum(p[i:i+k])
    if temp_sum > max_sum:
        max_sum = temp_sum
        max_where = i

result = 0

for j in range(k):
    result += ((p[max_where + j] + 1) * p[max_where + j] / 2) / p[max_where + j]

print(result)

Submission status: Time Limit Exceeded

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

box = []
ans = 0

for i in range(N-(K-1)):
    tmp = []
    for _ in range(i,K+i):
        tmp.append(p[_])
    box.append(sum(tmp))
max_p = box.index(max(box))

for j in range(0,K):
    ans += (1 + p[max_p+j])/2
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N-(K-1)):
    tmp = []
    for _ in range(i,K+i):
        tmp.append(p[_])
    box.append(sum(tmp))
max_p = box.index(max(box))

for j in range(0,K):
    dice = []
    for k in range(1,p[max_p + j]+1):
        dice.append(k)
    ex = 0
    P = 1/len(dice)
    for l in dice:
        Px = P*l
        ex += Px
    ans += ex
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n,k = readInts()
p = readInts()
#print(p)
maxValue = 0
ans = 0
for i in range(n-k+1):
	if maxValue<sum(p[i:i+k]):
		maxValue = sum(p[i:i+k])
		memo = p[i:i+k]

for i in range(k):
	ans+=(memo[i]+1)/2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
p = nl()

def exp(num):
  ret = (1+num)/2
  return ret

mx=0

pp = list(map(exp,p))

for i in range(n-k+1):
  mx = max(sum(pp[i:i+k]),mx)
print(mx)

Submission status: Time Limit Exceeded

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
p = nl()

def exp(num):
  ret = (1+num)/2
  return ret

mx=0

for i in range(n-k+1):
  mx = max(sum(map(exp,p[i:i+k])),mx)
print(mx)

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

Solution code:
# ABC154 D Dice in Line

n, k = map(int, input().split())
p_list = [int(x) for x in input().split()]
e_list = [None]*n

for i in range(n):
    e_list[i] = (1 + p_list[i])/2

ans = 0
for i in range(n-k+1):
    _ = sum(e_list[i:i+k])
    if ans < _:
        ans = _

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def cal_expected_value(num):
    return (num + 1) * num / 2 / num

def find_max_index(k, x_list):
    sum_list = []
    for i in range(len(x_list)-k+1):
        sum_amount = sum(x_list[i:i+k])
        sum_list.append(sum_amount)
    return sum_list.index(max(sum_list))

if __name__ == "__main__":
    N, K = map(int, input().split())
    p_list = list(map(int, input().split()))

    target_index = find_max_index(K, p_list)

    E_max = 0
    for i in p_list[target_index : target_index+K]:
        E_max += cal_expected_value(i)
    
    print(E_max)

Submission status: Time Limit Exceeded

Solution code:
def cal_expected_value(num):
    total = 0
    for j in range(1, num+1):
        total += j
    return total / num

def find_max_index(k, x_list):
    sum_list = []
    for i in range(len(x_list)-k+1):
        sum_amount = sum(x_list[i:i+k])
        sum_list.append(sum_amount)
    return sum_list.index(max(sum_list))

if __name__ == "__main__":
    N, K = map(int, input().split())
    p_list = list(map(int, input().split()))

    target_index = find_max_index(K, p_list)

    E_max = 0
    for i in p_list[target_index : target_index+K]:
        E_max += cal_expected_value(i)
    
    print(E_max)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
f=lambda x:0.5*(x+1)
p=list(map(f,p))
ans=0.
for i in range(n-k+1):
    ans=max(ans,sum(p[i:i+k]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = [int(x) for x in input().split()]
score = [0]*n
for i in range(n):
    score[i] = (1+p[i])/2

maxans = 0
for i in range(n-k+1):
    sums = sum(score[i:i+k])
    if(maxans < sums):
        maxans = sums
    
    
print(maxans)

Submission status: Time Limit Exceeded

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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

    ans = [0] * N
    max_tmp = [0] * K
    start_index = 0
    for i in range(N - K + 1):
        tmp = P[i: i + K]
        ans[i] = sum(list(range(1, P[i] + 1))) / P[i]
        if sum(max_tmp) < sum(tmp):
            max_tmp = tmp
            start_index = i

    for i in range(N - K, N):
        ans[i] = sum(list(range(1, P[i] + 1))) / P[i]

    print(sum(ans[start_index: start_index + K]))


resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_max = 0
    max_idx = 0
    for i in range(n - k + 1):
        max_tmp = 0
        for j in range(k):
            max_tmp += p[i+j]
        if sum_max < max_tmp:
            max_idx = i
            sum_max = max_tmp
    #print(max_idx)
    ans = 0
    for i in range(max_idx, max_idx + k):
        ans += ((p[i] * (p[i] + 1)) / 2) / p[i]
    print("{:.12f}".format(ans))
    return 0

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    p = list(map(int,sys.stdin.readline().split()))
    sum_max = 0
    max_idx = 0
    for i in range(n - k + 1):
        max_tmp = 0
        for j in range(k):
            max_tmp += p[i+j]
        if sum_max < max_tmp:
            max_idx = i
            sum_max = max_tmp
    #print(max_idx)
    ans = 0
    sigma = [i for i in range(1,1000)]
    for i in range(max_idx, max_idx + k):
        ans += sum(sigma[:p[i]]) / p[i]
    print("{:.12f}".format(ans))
    return 0

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
count = 0
for i in range(n):
    if q[0] < p[i]:
        q.popleft()
        q.append(p[i])
        count = max(count, sum(q))
    else:
        q.popleft()
        q.append(p[i])
if count % 2 == 0:
    print(ex_even(count) + 0.5*(k-1))
else:
    print(ex_odd(count) + 0.5*(k-1))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
count = 0
for i in range(n):
    q.popleft()
    q.append(p[i])
    count = max(count, sum(q))
if count % 2 == 0:
    print(ex_even(count) + 0.5*(k-1))
else:
    print(ex_odd(count) + 0.5*(k-1))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
c_max = 0
for i in range(1,n+1):
    if p[i-1] % 2 == 0:
        ex = ex_even(p[i-1])
        if ex > q[0]:
            q.popleft()
            q.append(ex)
            c_max = max(c_max, sum(q))
        else:
            q.popleft()
            q.append(ex)
    else:
        ex = ex_odd(p[i-1])
        if ex > q[0]:
            q.popleft()
            q.append(ex)
            c_max = max(c_max, sum(q))
        else:
            q.popleft()
            q.append(ex)
print(c_max)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
c_max = 0
for i in range(1,n+1):
    if p[i-1] % 2 == 0:
        ex = ex_even(p[i-1])
        q.popleft()
        q.append(ex)
    else:
        ex = ex_odd(p[i-1])
        q.popleft()
        q.append(ex)
    c_max = max(c_max, sum(q))
print(c_max)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    li = []
    for i in range(1, b+1):
        li.append(i)
    return li[len(li)//2]
ans = [0] * k
q = deque(ans)
c_max = 0
for i in range(1,n+1):
    if p[i-1] % 2 == 0:
        ex = ex_even(p[i-1])
        q.popleft()
        q.append(ex)
    else:
        ex = ex_odd(p[i-1])
        q.popleft()
        q.append(ex)
    c_max = max(c_max, sum(q))
print(c_max)

Submission status: Time Limit Exceeded

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

for i in range(N-K+1):
  r = max(r,sum(p[i:i+K]))
  
print((r+K)/2)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
def f(x):
    return sum(range(1, x + 1)) / x
p = [f(int(i)) for i in input().split()]
s = np.cumsum(p)
if k == 1:
    print(max(p))
elif k == n:
    print(s[-1])
else:
    print(max(s[k - 1:] - np.hstack([[0], s[:n - k]])))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
p = [np.sum(np.arange(1, int(i) + 1)) / float(i) for i in input().split()]
p = np.array(p)
s = np.cumsum(p)
m = s[k - 1]
for i in range(n - k):
    m = max(m, s[i + k] - s[i])
print(m)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, k = map(int, input().split())
p = [np.sum(np.arange(1, int(i) + 1)) / float(i) for i in input().split()]
p = np.array(p)
s = np.zeros(n - k + 1)
for i in range(n - k + 1):
    s[i] = np.sum(p[i: i + k])
print(s.max())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
l = list((i+1)/2 for i in l)
#print(l)
ma = 0
for i in range(n-k+1):
  a = sum(l[i:k+i])
 # print(l[i:k+i],a)
  ma = max(ma,a)
print(ma)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def kitai(pk):
    return sum(pk)/2 + k*0.5

ans = 0.0
for i in range(len(p)-k+1):
    karians = kitai(p[i:i+k])
    if ans < karians:
        ans = karians
print(ans)

Submission status: Time Limit Exceeded

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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    answer = 0
    means = list(map(lambda x: (1+x)/2, p))
    sum_list = [sum(means[:i]) for i in range(N+1)]
    for i in range(N-K+1):
        answer = max(answer, sum_list[i+K]-sum_list[i])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    answer = 0
    means = list(map(lambda x: (1+x)/2, p))
    for i in range(N-K+1):
        check = sum(means[i:i+K])
        if answer <= check:
            answer = check
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    answer = 0
    for i in range(N-K+1):
        check = sum(list(map(lambda x: (1+x)/2, p[i:i+K])))
        if answer <= check:
            answer = check
    print(answer)


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
for i in range(n-k+1):
    tmp = (sum(p[i:i+k])+k)/2
    if tmp > ans:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

expected_list = [(x+1)/2 for x in p_list]

maximum = 0
for i in range(n-(k-1)):
    maximum = max(maximum, sum(expected_list[i:i+k]))
print(maximum)

Submission status: Time Limit Exceeded

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

expected_list = [sum(range(1, x+1))/x for x in p_list]

maximum = 0
for i in range(n-(k-1)):
    maximum = max(maximum, sum(expected_list[i:i+k]))
print(maximum)

Submission status: Time Limit Exceeded

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

#p_iの期待値は(1+p_i)/2で求められる
ans=0

expected_value=[0]*n
for i in range(n-k+1):
    if i==0:
        for j in range(i+n-1):
            expected_value[j]=(1+p_input[j])/2
    expected_value[i+k-1]=(1+p_input[i+k-1])/2
    ans = max(sum(expected_value[i:i+k]),ans)

print(ans)

Submission status: Time Limit Exceeded

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

a = i = j = count = ans = 0

new_p = [0] * n

for i in range(n):
    for j in range(p[i]):
        new_p[i] += j+1
    new_p[i] = float(new_p[i]/p[i])

i = j = 0
total = 0
for i in range(k):
    total += new_p[i]
ans = total
for i in range(k,n):
    total = total + new_p[i] - new_p[i-k]
    ans = max(ans,total)

print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

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

def center(x):
    return sum(list(range(x+1)))/x

P = [center(p) for p in P]

print(max([sum(P[i:i+K]) for i in range(N-K+1)]))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
L = []
n = 0
l = 0
 
for p in range(N-K+1):
  for q in range(K):
    for r in range(D[p+q]+1):
      n = n + r
    f = n/D[p+q]
    l = l + f
    n = 0
  L.append(l)
  l = 0

print(max(L))

Submission status: Time Limit Exceeded

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

a = i = j = count = ans = 0

new_p = [0] * n

for i in range(n):
    for j in range(p[i]):
        new_p[i] += j+1
    new_p[i] = float(new_p[i]/p[i])

i = j = 0

while k <= n:
    total = 0
    for i in range(j,k):
        total += new_p[i]
    if ans < total:
        ans = total
    j += 1
    k += 1

print(ans)

Submission status: Time Limit Exceeded

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

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key
C = [D[p] for p in P]
T = [sum(C[i: i + k]) for i in range(0, n - k + 1)]

print(max(T))

Submission status: Time Limit Exceeded

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

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key

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

Submission status: Time Limit Exceeded

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

mx = max(P)
ans = 0.0
for i in range(0, n - k + 1):
    T = P[i: i + k]
    if mx in T:
        tmp = 0.0
        for t in T:
            M = [j for j in range(1, t + 1)]
            tmp += sum(M) / t
        ans = max(tmp, ans)
print(ans)

Submission status: Time Limit Exceeded

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

sum_of_selected = []

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

i = sum_of_selected.index(max(sum_of_selected))
part_of_p_for_calc = p[i: i+K]

# 期待値計算する
print(sum([sum([y*(1/x) for y in range(1, x+1)]) for x in part_of_p_for_calc]))