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:
def calc_exp(p):
    result = 0
    for n in p:
        result += expectation(n)
    return result


def expectation(n):
    return 0.5 * n + 0.5


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    max_num = 0
    max_idx = -1
    for i in range(n-k+1):
        num = sum(p[i:i+k])
        if num >= max_num:
            max_num = num
            max_idx = i
    print(calc_exp(p[max_idx:max_idx+k]))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



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

    print(total/2)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

max_sum = 0

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

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

Submission status: Time Limit Exceeded

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

l = 0
r = k

result = 0.0
while r != len(p)+1:
  this_res = 0.0
  for pi in p[l:r]:
    this_res += sum(map(lambda a : 1/pi * a, [x for x in range(1, pi+1)]))
  result = max(result, this_res)
  l += 1
  r += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int, input().split())
p = [(int(i)+1)/2 for i in input().split()]
ans = 0
for i in range(n-k+1):
    ans = max(sum(p[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(' ')))
max_list=[]
max_tmp = 0
ans = 0
for i in range(N-K+1):
    tmp = sum(P[i:i+K])
    if tmp > max_tmp:
        max_list=P[i:i+K]
        max_tmp = tmp
for i in max_list:
    ans += (i+1)/2
print(ans)

Submission status: Time Limit Exceeded

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

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

print((s+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, K = fetch_int_input()
p = fetch_int_input()

max_num = -999
tmp_nums = []
for i in range(N - K + 1):
    nums = p[i: i + K]
    sum_nums = sum(nums)
    if max_num < sum_nums:
        max_num = sum_nums
        tmp_nums = nums

ave_nums = [(i + 1) / 2 for i in tmp_nums]

print(sum(ave_nums))

Submission status: Time Limit Exceeded

Solution code:
def kitai(l):
  return (l+1)/2

n , k = map(int, input().split())
a = list(kitai(int(i)) for i in input().split())


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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    pN = list(map(lambda s: int(s) + 1, input().split()))

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

    print(ans)


main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def calc_expect(n):
    return (n+1) / 2


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

p_expect_list = list(map(calc_expect, p_list))

max_val = 0

for i in range(len(p_expect_list)):
    val = sum(p_expect_list[i:i+k])
    if val > max_val:
        max_val = val

print(max_val)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_ls = list(map(int, input().split()))
ave_ls = []
'''
if n == 1:
    ave_ls.append(p_ls[0]*0.5+1)
elif n == 2:
    ave_ls.append((p_ls[0]+p_ls[1])*0.5+1)
else:
    for i in range(n-2):
        ave_ls.append((p_ls[i]+p_ls[i+1]+p_ls[i+2])*0.5+1)
'''
for i in range(n-k+1):
    now_ave = 0
    for j in range(k):
        now_ave+=p_ls[i+j]
    ave_ls.append(now_ave*0.5+0.5*k)
print(max(ave_ls))

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
final = []
#最大のリストを選定
for i in range(0,n):
    if i + k > n:
        break
    ck = sum(p[i:i+k])
    if ck > max:
        final = p[i:i+k]
        max = ck

#計算
res = 0
for i in final:
    res += (i * (i + 1) / 2)/i
print(res)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p_2 = []
for i in range(n):
    if p[i]%2 == 0:
        p_2.append(p[i]//2+0.5)
    else:
        p_2.append(p[i]//2 + 1)
maxer = 0
for i in range(n-k+1):
    cnt = sum(p_2[i:i+k])
    if cnt >= maxer:
        maxer = cnt
print(maxer)

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 = 0
    for j in range(i, i + K):
        tmp += sum([n for n in range(1, P[j] + 1)]) / P[j]
    ans = max(ans, tmp)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

s = []
for i in range(K):
    s.append(p[i])

m = sum(s)
for i in range(K,N):
    s.pop(0)
    s.append(p[i])
    if sum(s) > m:
        m = sum(s)

m += K

print(m / 2)

Submission status: Time Limit Exceeded

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

max_count = 0

for i in range(n-k+1):
    count = sum(p_list[i:i+k])/2 + k/2
    max_count = max(max_count,count)

print(max_count)

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])+k)
print(ans/2)

Submission status: Time Limit Exceeded

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

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

# 1 - pi
ans = 0
for i in range(len(p)-k + 1):
    exp = 0
    for idx in range(i, i+k):
        exp += (p[idx] + 1) / 2
    ans = max(ans, exp)

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

Submission status: Time Limit Exceeded

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

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

for i in range(idx,idx+k):
    e1 = (1 + p[i])*(p[i]//2 + 0.5*(p[i]%2))/p[i]
    e += e1

print(e)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
N, K = map(int,input().split())
P = list(map(int,input().split()))
P = [(p+1)/2 for p in P]
mx = 0
for i in range(N-K+1):
    mx = max(mx,sum(P[i:K+i]))
print (mx)

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/2*i*(i+1))/i)

for i in range(N-K+1):
    ans.append(sum(ex[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()))

ans=0
for i in range(n-k+1):
  tmp=0
  for j in range(k):
    tmp+=((1/2)*P[i+j]*(P[i+j]+1)) / P[i+j]
  ans=max(ans,tmp)
print(ans)

Submission status: Time Limit Exceeded

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

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

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

#print(p[check:check+k])

ans = 0
for i in p[check:check+k]:
    ans += (i+1)/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 = sum(_p[i:i+k])
    if _ans > ans:
        ans = _ans
print(ans)

Submission status: Time Limit Exceeded

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

max_val = 0
for i in range(n-k+1):
    x = sum(l[i:i+k])
    if x > max_val:
        max_val = x

print((max_val+k)*1.0/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
ans = 0
i = 0
while i <= N-K:
    tmp = p[i:i+K]
    ans = max(ans,(sum(tmp)+K)/2)
    i += 1
print(ans)

Submission status: Time Limit Exceeded

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


def main():
    N, K = map(int, input().split())
    ps = [(int(s)+1)/2 for s in input().split()]

    m = 0
    for i in range(N):
        left = i
        right = min(i+K, N)

        s = sum(ps[left:right])
        m = max(m, s)

    print(m)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

tmp = []
for p in pl:
    ii = 0
    for i in range(1, p+1):
        ii += i
    tmp.append(ii/p)

ans = 0
for i in range(n-k+1):
    if sum(tmp[i:i+k]) > ans:
        ans = sum(tmp[i:i+k])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,K = inputMap()
	P = inputList()

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

		anstmp = 0
		for j in range(K):
			tmp = P[i+j]
			total = 0
			for jj in range(1,tmp+1):
				total += jj
			anstmp += total/tmp

		if anstmp > ans:
			ans = anstmp

	print(ans)

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

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

    ans = 0
    for i in range(N + 1 - K):
        ans = max(ans, sum(map(lambda x: 1 + x, pN[i:i + K])) / 2)

    print(ans)


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):
    s = (sum(p[i : i + K]) + K) / 2
    if s > ans:
        ans = s
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def run():
  N, K = map(int, input().split())
  ps = list(map(int, input().split()))
  dp = [0]*(N-K+1)
  ans = 0
  dp[0] = sum(ps[0:K])
  for n in range(1, N-K+1):
    dp[n] = max(dp[n-1], sum(ps[n:n+K]))
  print((dp[-1]+K)/2)

if __name__ == '__main__':
    run()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

per = [ (n + 1) / 2 for  n in P]

MAX = -1
for x in range(N - K + 1):
    temp = sum(per[x : x + K])
    if MAX < temp:
        MAX = temp

print(MAX)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x: x * (x + 1) / (2 * x), p))

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    eval = [ (1+pi)*0.5  for pi in p ]
    sums = [ sum(eval[i:i+K]) for i in range(N-K+1) ]
    print(max(sums))
    return

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

E = [(i + 1)/2 for i in p]
ans = 0
for i in range(N - K + 1):
    s = sum(E[i:i+K])
    if ans < s:
        ans = s
print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
score = []
for p in p_list:
    score.append((p + 1) / 2)

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

Submission status: Time Limit Exceeded

Solution code:

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

expect_list = [((1+yokolist[i])/2) for i in range(n)]

#print(expect_list)

answer = 0
l = expect_list[0:k]
for j in range(n-k+1):
    p = sum(l)
    if p > answer:
       answer = p
    del l[0]
    if j != n-k:
        l.append(expect_list[k+j])

print(answer)

Submission status: Time Limit Exceeded

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

n, k = map(int, input().split())
lst = list(map(int, input().split()))
exlst = [ex(l) for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = [0 for i in range(K)]
    for i in range(K):
        l[i] = (p[i]*(p[i]+1))//2/p[i]
    ans = sum(l)
    for i in range(K, N):
        l[i%K] = (p[i]*(p[i]+1))//2/p[i]
        tmp = sum(l)
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    res = 0
    maxI = 0
    maxV = 0
    for i in range(N-K+1):
        v = sum(P[i:i+K])
        if v > maxV:
            maxV = v
            maxI = i
    # print(maxI)
    for p in P[maxI:maxI+K]:
        res += (1.0/p) * sum(list(range(p+1)))
    print(res)



    

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

exarr = [(i+1)/2 for i in arr]
sol = 0

for i in range(n-k+1):
    tmpsum = sum(exarr[i:i+k])
    sol = max(sol,tmpsum)
    
print(sol)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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())
lst = list(map(int, input().split()))
ans = []

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

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

Submission status: Time Limit Exceeded

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

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

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(k - 1, len(p)):
    ans = max(ans, sum(p[i - k + 1:i + 1]))

print((ans + k) / 2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

cnt = 0
dice = [(i+1)/2 for i in p]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

idx = -1
m = 0
for i in range(n-k+1):
    s = sum(p[i:i+k])
    if m < s:
        m = s
        idx = i

ans = 0
for i in p[idx:idx+k]:
    ans += (i - 1) * 0.5 + 1
print('{:.12f}'.format(float(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(0, n-k+1):
    x = 0
    for j in range(k):
        x += (p[i+j] + 1)/2
    ans = max(ans, x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
max_l = [0]*K
for i in range(N):
  tmp_l = p[i:i+K]
  if sum(tmp_l) > sum(max_l):
    max_l = tmp_l
print(sum([(n+1)/2 for n in max_l]))

Submission status: Time Limit Exceeded

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

e_table = [0]
pre = 0
for i in range(1,1001):
    e_table.append((pre + i)/i)
    pre = pre + i

lis = [0] * K

maximam = 0

for p in input().split():
    p = int(p)
    lis = lis[1:]
    lis.append(e_table[p])
    maximam = max(maximam, sum(lis))
print(maximam)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
n,k = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
p = list(map(int, stdin.readline().rstrip().split()))

ans = 0

for i in range(n-k+1):
    sums = 0
    for j in range(k):
        num = p[i+j]
        sum = 0
        for u in range(num):
            sum += u+1
        sum = sum/num
        sums += sum
    ans = max(ans, sums)

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):
  tmp = sum(p[i:i+k])
  if tmp > m :
    m = tmp
print((m + k)/2)

Submission status: Time Limit Exceeded

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    temp=0
    max=0
    maxi=0
    for i in range(n-k+1):
        temp=sum(p[i:i+k])
        if temp>max:
            max=temp
            maxi=i
    total=0
    for i in range(maxi,maxi+k):
        total+=(1+p[i])/2

    print(total)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def run():
  N, K = map(int, input().split())
  ps = list(map(int, input().split()))
  dp = [0]*(N-K+1)
  dp[0] = sum(ps[0:K])
  for n in range(1, N-K+1):
    dp[n] = max(dp[n-1], sum(ps[n:n+K]))
  print((dp[-1]+K)/2)

if __name__ == '__main__':
    run()

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

p_list = [0] * len(p)
for i in range(n):
    p_list[i] = (p[i] + 1) / 2

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

print(ans)

Submission status: Time Limit Exceeded

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

    expect = [((p + 1) / 2.0) for p in P]
    sum_exp = [sum(expect[i:i + K]) for i in range(N - K + 1)]
    print(max(sum_exp))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
v_list = list(map(int, input().split()))
max_val = 0
for i in range(n+1-k):
  last_index = i + k
  use_list = v_list[i:last_index]
  val = (sum(use_list) + k) / 2
  if val > max_val:
    max_val = val
print(max_val)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

p = list(map(int, input().split()))
hope_list = []

for i in p:
    hope_list.append((i+1)*0.5)

max = 0
for j in range(n-k+1):
    b = hope_list[j:j+k]
    goukei = sum(hope_list[j:j+k])
    if goukei > max:
        max = goukei

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
c=0
for i in range(n-k+1):
    if sum(p[i:i+k])>=c:
        c=sum(p[i:i+k])
        ans=c/2+0.5*k
        #print(c,ans)
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):
  p[i]=(p[i]+1)/2
for i in range(N-K+1):
  ans=max(ans,sum(p[i:i+K]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

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

    print((ans+K)/2)

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
P = [int(i) for i in input().split()]
max_p = 0
for n in range(N-K+1):
    temp = 0
    for k in range(K):
        temp += (P[n+k] + 1) / 2
    max_p = max(max_p,temp)
print(max_p)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
ma = 0
for i in range(n-k+1):
    lin = li[i:i+k]
    point = 0
    if len(lin) != k:
        break
    for j in lin:
        point += (1+j)/2
    ma = max(ma,point)
print(ma)

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
arr = list(map(int, input().split()))
mx_sum = 0
idx = 0
for i in range(N):
    if N <= i + K - 1:
        break
    val = sum(arr[i:i+K])
    if mx_sum <= val:
        mx_sum = val
        idx = i

ans = 0
for i in range(idx, idx+K):
    ans += (arr[i] + 1) / 2
print(ans)

Submission status: Time Limit Exceeded

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

d = {}
for i in range(1, 1001):
    d[i] = (i + 1) * (i / 2) / i

ans = 0
for i in range(N-K+1):
    total = 0
    for j in range(K):
        total += d[P[i+j]]
    ans = max(ans, total)

print(ans)

Submission status: Time Limit Exceeded

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

e = [0] * N

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

ans = 0

for i in range(N - K + 1):
    total = sum(e[i:i + K])
    if total > ans:
        ans = total

print(ans)

Submission status: Time Limit Exceeded

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

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

    print((max_sum + k) / 2)

resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
ex = [(x + 1) / 2 for x in nums]

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

E = [sum(range(1, i+1)) / i for i in p]
ans = 0
for i in range(N - K + 1):
    s = sum(E[i:i+K])
    ans = max([ans, s])
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):
  x = (sum(p[i : K + i]) + K) / 2
  #print(x)
  ans = max(x, ans)
  
print(ans)

Submission status: Time Limit Exceeded

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