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()))
Q = [ ((i*(i+1))/2)/i for i in p]
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:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n, k = map(int, input().split())
p = np.array(list(int(i) for i in input().split()))
pp = (1 + p) / 2
# print(p)
# print(pp)
ans = 0.00

for i in range(0, n - k + 1):
	ans = max(np.sum(pp[i : (i + k)]), ans)
print('{:.10f}'.format(ans))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n, k = map(int, input().split())
p = list(float(i) for i in input().split())
ans = 0

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

mx = 0

s = 0

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

print(mx / 2)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
mx = 0
for i in range(a):
    ar[i] += 1
    ar[i] /= 2
for i in range((a-b) + 1):
    c = sum(ar[i:i+b])
    if mx < c:
        mx = c
print(mx)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = []
for i in range((a+b)-1):
    c = sum(ar[i:i+b])
    br.append(c)
print((max(br) + b)/ 2)

Submission status: Time Limit Exceeded

Solution code:
def cal_expected(x) :
    return (x + 1) / 2

def sum_dice(k, p) :
    sum = 0
    for i in range(k) :
        sum += p[i]
    return sum


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

for i in range(n) :
    p[i] = cal_expected(p[i])

max_exp = 0
for i in range(n - k + 1) :
    tmp = sum_dice(i + k, p) - sum_dice(i, p)
    # print(tmp)
    if tmp > max_exp :
        max_exp = tmp

print(max_exp)

Submission status: Time Limit Exceeded

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

for i, p_i in enumerate(p):
  p[i] = (1+p_i)/2

e_v = []
for j in range(n-k+1):
  e_v.append(sum(p[j:j+k]))

print(max(e_v))

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate

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

max_idx = 0
max_val = 0

for i in range(N - K + 1):
	val = sum(P[i:i+K])
	if max_val < val:
		max_val = val
		max_idx = i

print((sum(P[max_idx:max_idx+K]) + K) / 2)

Submission status: Time Limit Exceeded

Solution code:
def cal_expected(x) :
    return (x + 1) / 2


n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
max_element = 0
max_key = 0
for i in range(n - k + 1) :
    tmp = 0
    for j in range(i, i + k) :
        tmp += p[j]
    nums.append(tmp)
    if nums[i] > max_element :
        max_element = nums[i]
        max_key = i

ans = 0
for i in range(max_key, max_key + k) :
    ans += cal_expected(p[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def cal_expected(x) :
    num = 0
    for i in range(x + 1) :
        num += i
    return num / x


n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
max_element = 0
max_key = 0
for i in range(n - k + 1) :
    tmp = 0
    for j in range(i, i + k) :
        tmp += p[j]
    nums.append(tmp)
    if nums[i] > max_element :
        max_element = nums[i]
        max_key = i

ans = 0
for i in range(max_key, max_key + k) :
    ans += cal_expected(p[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:



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


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

# 制約より
MAX_DICE = 1000*K

# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos
maxvalue = sum(dices[maxpos:maxpos+K])

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > maxvalue:
        maxpos = pos
        maxvalue = sum(dices[pos:pos+K])

        # 上限
        if maxvalue == MAX_DICE:
            break

# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

Submission status: Time Limit Exceeded

Solution code:



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


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


# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > sum(dices[maxpos:maxpos+K]):
        maxpos = pos


# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

Submission status: Time Limit Exceeded

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

Q = [((v + 1) / 2) for v in P]

MAX = 0.0

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

print(MAX)

Submission status: Time Limit Exceeded

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

Q = [(float(v + 1) / 2) for v in P]

MAX = 0.0

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

print(MAX)

Submission status: Time Limit Exceeded

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

MAX = 0.0

for i in range(N - K + 1):
	val = sum((P[i + j] - 1) * 0.5 + 1.0 for j in range(K))
	if val > MAX:
		MAX = val

print(MAX)

Submission status: Time Limit Exceeded

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

MAX = 0.0

for i in range(N - K + 1):
	val = sum([(P[i + j] - 1) * 0.5 + 1.0 for j in range(K)])
	if val > MAX:
		MAX = val

print(MAX)

Submission status: Time Limit Exceeded

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

Q = [(float(v - 1) * 0.5 + 1.0) for v in P]

MAX = 0.0

for i in range(N - K + 1):
	val = sum([Q[i + j] for j in range(K)])
	if val > MAX:
		MAX = val

print(MAX)

Submission status: Time Limit Exceeded

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

start = 0
max = 0
for i in p[:len(p)-k+1]:
    res = 0.0000000000000
    for j in p[start:start+k]:
        res += 1 + j
    if max < res:
        max = res
    start += 1

print(max/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cum = [0]
for i in range(1, n+1):
    cum.append(cum[i-1] + (p[i-1]+1)/2)

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

print(cum[idx+k]-cum[idx])

Submission status: Time Limit Exceeded

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

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

cum = [0]
for i in range(1, n+1):
    cum.append(cum[i-1] + mean[p[i-1]])

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

print(cum[idx+k]-cum[idx])

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

def expc(x):
    return (x + 1.0)/2.0

sum_max = sum(expc(p_array[0:k]) )
temp_sum = sum_max
for i in range(n-k):
    temp_sum -= expc(p_array[i])
    temp_sum += expc(p_array[i+k])
    if temp_sum > sum_max:
        sum_max = temp_sum

print(sum_max)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
y = 0


def f(n):
    x = 0
    for i in range(n + 1):
        x += i
    return x / n


for j in range(n - k + 1):
    z = 0
    for i in range(k):
        z += p[-i - 1]
    if z > y:
        y = z
        a = 0
        for l in range(k):
            a += f(p[-l - 1])
    p.pop()

print(a)

Submission status: Time Limit Exceeded

Solution code:
def e_cal(dice_list):
    e_list = []
    for dice in dice_list:
        e = 0
        for i in range(dice):
            e = (i+1) * (1/dice) + e
        e_list.append(e)
    return e_list
line1 = input()
line2 = input()
n, k =line1.split(" ")
n = int(n)
k = int(k)
dice_list = line2.split(" ")
dice_list = [int(i) for i in dice_list]
e_list = e_cal(dice_list)

max_e = 0
for i in range(n-(k-1)):
    temp_e = 0
    for j in range(k):
        temp_e = temp_e + e_list[i+j]
    if max_e < temp_e:
        max_e = temp_e
print(max_e)

Submission status: Time Limit Exceeded

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

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

def calc_e(p):
    temp = 0.5 + 0.5 * p
    return temp

temp_max = 0
temp_i = 0

for i in range(N - K + 1):
    temp = sum(P[i:i+K])
    if temp_max <= temp:
        temp_max = temp
        temp_i = i


temp = 0
temp = calc_e(temp_max // K) * (K - 1) + calc_e(temp_max // K + temp_max % K)
print(temp)

Submission status: Time Limit Exceeded

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

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

def calc_e(p):
    temp = 0
    for i in range(1, p + 1):
#        temp += i * (1 / p)
        temp = 0.5 + 0.5 * p
    return temp

temp_max = 0
temp_i = 0

for i in range(N - K + 1):
    temp = sum(P[i:i+K])
    if temp_max <= temp:
        temp_max = temp
        temp_i = i


temp = 0
for i in range(temp_i,temp_i + K):
    temp += calc_e(P[i])
print(temp)

Submission status: Time Limit Exceeded

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

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

def calc_e(p):
    temp = 0
    for i in range(1, p + 1):
        temp += i * (1 / p)
    return temp

temp_max = 0
temp_i = 0

for i in range(N - K + 1):
    temp = sum(P[i:i+K])
    if temp_max <= temp:
        temp_max = temp
        temp_i = i


temp = 0
for i in range(temp_i,temp_i + K):
    temp += calc_e(P[i])
print(temp)

Submission status: Time Limit Exceeded

Solution code:
def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	# print(a)
	exp = [(1/2 * a[0] * (a[0] +1))/a[0]]
	wa = [0,(1/2 * a[0] * (a[0] +1))/a[0]]
	for i in range(1,n):
		# print(a[i]) 
		exp.append((1/2 * a[i] * (a[i]+1))/a[i])
		wa.append(wa[i] + (1/2 * a[i] * (a[i]+1))/a[i])
	# print(exp)
	# print(len(wa))
	ans = sum(exp[0:m])
	for i in range(m,len(wa)+1):
		# print(i)
		ans = max(sum(exp[:i])-sum(exp[:i-m]),ans)
	print(ans)
	
 
if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	# print(a)
	maxl = [sum(a[0:m])]
	# print("maxl = {}".format(maxl))
	i = 1
	while i + m <= len(a):
		maxl.append(max(sum(a[i:i+m]),maxl[-1]))
		# print("sum = {}".format(sum(a[i:i+m])))
		# print("maxl = {}".format(maxl))
		i += 1
		# print(i)
	# print(maxl)
	ans = 0
	# print("a max is {}".format(a[maxl.index(max(maxl))]))
	for i in range(0,m):
		# print("i is {}".format(i))
		n = a[maxl.index(max(maxl)) + i]
		# print("n is {}".format(n))
		ans += (1/2 * n * (n+1))/a[maxl.index(max(maxl)) + i]
	print(ans)
	
 
if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

result = 0
for i in range(k):
    result += sum(range(1,p[idx+i]+1))/p[idx+i]

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

N,K=map(int,input().split())
a=list(map(int,input().split()))
tmp=10**-10
l=[]
for i in range(N-K+1):
  s=sum(a[i:i+K])
  if s>tmp:
    l=a[i:i+K]
    tmp=s

ans=(tmp+K)/2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
tmp=10**-10
l=[]
for i in range(N-K+1):
  s=sum(a[i:i+K])
  if s>tmp:
    l=a[i:i+K]
    tmp=s
ans=0
for i in range(K):
  v=l[i]
  ans+=((v+1)/2)
print(ans)

Submission status: Time Limit Exceeded

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

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

t = 0
for i in range(K):
    t += A[i]
L = (t,)

ans = 0

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

Submission status: Time Limit Exceeded

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

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

t = 0
for i in range(N[1]):
    t += A[i]

L = (t,)

for i in range(N[0]-N[1]):
    L  = L + (L[i] + A[N[1]+i]-A[i] ,)
print(max(L))

Submission status: Time Limit Exceeded

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

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

t = 0
for i in range(N[1]):
    t += A[i]

L = (t,)

for i in range(N[0]-N[1]):
    L  = L + (L[i] + A[N[1]+i]-A[i] ,)
print(max(L))

Submission status: Time Limit Exceeded

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

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

L = [0]*(N[0]-N[1]+1)

for i in range(N[0]-N[1]+1):
    for j in range(N[1]):
        L [i] += A[i+j]
print(max(L))

Submission status: Time Limit Exceeded

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

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

def s_(x):
    t = 0
    for i in range(x+1):
        t += i
    return t / x

total = 0
A = []
for i in range(n - k + 1):
    s = sum(P[i:i+k])
    if total < s:
        total = s
        A = P[i:i+k]
sum_ = 0
for i in A:
    sum_ += s_(i)
print(sum_)

Submission status: Time Limit Exceeded

Solution code:
import sys
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
P = list(map(int, inputs[1].split()))
EP = [0.5*p + 0.5 for p in P]

print(max(sum(EP[i:i+k]) for i in range(n-k+1)))

Submission status: Time Limit Exceeded

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

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

A = []
B = []
C = []

def s_(x):
    t = 0
    for i in range(x+1):
        t += i
    return t / x


for i in P:
    if i not in A:
        A.append(i)
        B.append(s_(i))
        C.append(B[-1])
    else:
        C.append(B[A.index(i)])
max_ = 0
for j in range(n - k + 1):
    g = sum(C[j:j+k])
    if max_< g:
        max_ = g
print(max_)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

sum = 0
temp = 0
for i in range(len(p) - k + 1):
    sum = 0
    for j in range(k):
        sum += val[i+j]
    if sum > temp:
        temp = sum
print(temp)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

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

a = deque(p[:k])
ans = sum(a)

for i in range(n-k):
    a.popleft()
    a.append(p[i+k])
    A = sum(a)
    if A > ans:
        ans = A
        continue

ans = (ans+k)/2

print(ans)

Submission status: Time Limit Exceeded

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

for y in range(nn):
    wk = 0
    for x in range(y,k+y):
        wk = wk + li[x]
    kai.append(wk)
 
print(max(kai))

Submission status: Time Limit Exceeded

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

maxexp = 0
for i in range(n-k+1):
    kdice = [float((1+p[i+j])/2) for j in range(k)]
    sumkdice = sum(kdice)
    if sumkdice > maxexp:
        maxexp = sumkdice

print(maxexp)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
e=[c[i] for i in range(b)]

for i in range(1,a-b+1):
    mn=min(e)
    if mn<=c[i]:
        su=[]
        for n in range(b):
            su.append(c[n+i])
        if sum(su)>sum(e):
            e=su
print(sum([(e[i]+1)/2 for i in range(b)]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [0]*(N[0]-N[1]+1)

for i in range(N[0]-N[1]+1):
    for j in range(N[1]):
        for k in range(A[i+j]):
            L[i] += (k+1)/A[i+j]

print(max(L))

Submission status: Time Limit Exceeded

Solution code:
straights=[]
nk =input().rstrip().split(" ")
n =int(nk[0])
k =int(nk[1])
numbers =input().rstrip().split(" ")
for i in range(n-k+1):
    wa=0
    for j in range(k):
        wa =wa+int(numbers[i+j])
    straights.append(wa)
#print(straights)
straights2 =sorted(straights, reverse=True)
#print(straights2)
sigma=straights2[0]
answer =(sigma+k)/2
print(answer)

Submission status: Time Limit Exceeded

Solution code:
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

nk = input()
textp = input()

N = int(get(nk,2)[0])
K = int(get(nk,2)[1])
ps = get(textp,N)
for i in range(N):
    ps[i] = int(ps[i])

exp = [0] * N
for i in range(N):
    exp[i] = (ps[i]+1)/2

m = 0
for i in range(N-K+1):
    s = 0
    for j in range(K):
        s = s + exp[i+j]
    if m < s:
        m = s

print(m)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

max_P = []
max = 0
for i in range(N-K+1):
    tmp = P[i:i+K]
    sum_dice = np.sum(tmp)
    if sum_dice > max:
        max = sum_dice
        max_P = tmp

ans = np.sum((np.array(max_P)+1)/2)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

max_P = []
max = 0
for i in range(N-K+1):
    tmp = P[i:i+K]
    sum_dice = np.sum(tmp)
    if sum_dice > max:
        max = sum_dice
        max_P = tmp

ans = 0
for p in max_P:
    ans += np.sum(np.arange(1,p+1))/p

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

max_P = []
max = 0
for i in range(N-K+1):
    sum_dice = np.sum(P[i:i+K])
    if sum_dice > max:
        max = sum_dice
        max_P = P[i:i+K]

ans = 0
for p in max_P:
    ans += np.sum(np.arange(1,p+1))/p

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int,input().split())
p = list(map(int,input().split()))
max_k = 0
max_i = 0
for i in range(n-k+1):
    if sum(p[i:i+k]) > max_k:
        max_k = sum(p[i:i+k])
        max_i = i
ans = 0.0
for j in range(k):
    ans+= (p[max_i+j]+1)/2.0
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
expect_list = np.array(p_list)
expect_list = (expect_list + 1)/2
sum_list = []
#print(expect_list)

for i in range(N-K+1):
    sum=0
    for j in range(K):
        sum += expect_list[i+j]

    sum_list.append(sum)

print(max(sum_list))

Submission status: Time Limit Exceeded

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

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

dices = p[maxIndex[0]:maxIndex[1]]
exs = 0
for dice in dices:
  exs += sum(list(range(1, dice+1))) / dice
print(exs)

Submission status: Time Limit Exceeded

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

maxNum = -1
maxIndex = [0, 0]
for i in range(n-k+1):
  s = 0
  for j in range(i, i+k, 1):
    s += p[j]
  if s > maxNum:
    maxNum = s
    maxIndex = [i, i+k]

dices = p[maxIndex[0]:maxIndex[1]]
exs = 0
for dice in dices:
  e = 0
  for i in range(1, dice+1):
    e += i 
  exs += e /dice
print(exs)

Submission status: Time Limit Exceeded

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


maxNum = -1
maxIndex = [0, 0]
for i in range(n-k+1):
  s = 0
  for j in range(i, i+k, 1):
    s += p[j]
  if s > maxNum:
    maxNum = s
    maxIndex = [i, i+k]

dices = p[maxIndex[0]:maxIndex[1]]
exs = 0
for dice in dices:
  e = 0
  for i in range(1, dice+1):
    e += i / dice
  exs += e
print(exs)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

exs = []
for i in range(n-k+1):
  exsum = 0
  for j in range(i, i+k, 1):
    ex = 0
    for l in range(1, p[j]+1, 1):
      ex += l / p[j]
    exsum += ex
  exs.append(exsum)
print(max(exs))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
max_v = 0
mark = 0

for i in range(n-k+1):
    #print(sum (p[i:k+i]),'i',i,'k',k,'k+i',k+i)
    temp = sum (p[i:k+i])
    if max_v < temp:
        mark = i
        max_v = temp

#print(mark)
    
def expectation(x):
    expectation_v = 0.5 *(1+x)
    return expectation_v

p_list = p[mark:mark+k]

for a in p_list:
    ans += expectation(a)

#for i in range(mark,mark+k):
    #ans += expectation(p[i])
    
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

max_v = 0
mark = 0

for i in range(n-k+1):
    #print(sum (p[i:k+i]),'i',i,'k',k,'k+i',k+i)
    temp = sum (p[i:k+i])
    if max_v < temp:
        mark = i
        max_v = temp

#print(mark)
    
def expectation(x):
    expectation_v = 0.5 *(1+x)
    return expectation_v

for i in range(mark,mark+k):
    ans += expectation(p[i])
    
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

max_v = 0
mark = 0

for i in range(n-k+1):
    #print(sum (p[i:k+i]),'i',i,'k',k,'k+i',k+i)
    if max_v < sum (p[i:k+i]):
        mark = i
        max_v = sum (p[i:k+i])

#print(mark)
    
def expectation(x):
    expectation_v = 0.5 *(1+x)
    return expectation_v

for i in range(mark,mark+k):
    ans += expectation(p[i])
    
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:


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

ans = 0

max_v = 0
mark = 0

for i in range(n-k+1):
    #print(sum (p[i:k+i]),'i',i,'k',k,'k+i',k+i)
    if max_v < sum (p[i:k+i]):
        mark = i
        max_v = sum (p[i:k+i])

#print(mark)
    
def expectation(x):
    expectation_v = 0
    for i in range(1,x+1):
        expectation_v += i
    expectation_v = expectation_v/x
    return expectation_v

for i in range(mark,mark+k):
    ans += expectation(p[i])
    
    
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

dst = 0.0

for i in range(N-K+1):
    p_sum = 0.0
    for j in range(K):
        p = p_list[i+j]
        p_sum += ( p/2 * (1+p)) / p
    if p_sum > dst:
        dst = p_sum
    
print(dst)

Submission status: Time Limit Exceeded

Solution code:
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = 0
for i in range(n-k+1):
  maximum = max(maximum, sum(input_list[i:i+k]))

print( (maximum + k) / 2 )

Submission status: Time Limit Exceeded

Solution code:
import numpy as	np
N,K=map(int,input().replace('\n','').split())
P=list(map(int,input().replace('\n','').split()))

m=-1.0
for i in range(N-K+1):
  if np.sum(P[i:i+K])>=m:
    m=np.sum(P[i:i+K])
    ml=P[i:i+K]

print((m+K)/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def get_expected_value(max_num):
  return (max_num + 1) / 2
    
dice_list = [int(s) for s in input().rstrip().split(' ')]
appearance_list = [int(s) for s in input().rstrip().split(' ')]
expected_list = [get_expected_value(ap) for ap in appearance_list]

index = 0
sum_list = []
target_len = dice_list[1]
while index + target_len <= dice_list[0]:
  sum_list.append(sum(expected_list[index:index+target_len]) / target_len)
 
print(max(sum_list))

Submission status: Time Limit Exceeded

Solution code:
#1からaまでのa種類の目がそれぞれ等確率で出るサイコロの期待値を求める関数
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())
D=list(map(int,input().split()))
DE=list(map(kitaiti,D))

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

print(anse)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
    count = 0
    for j in range(k):
        count += p[i+j] + 1
    if count > s:
        s = count

s = s/2
print(s)

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):
    count = 0
    for j in range(k):
        count += p[i+j]/2 + 0.5
    if count > s:
        s = count

print(s)

Submission status: Time Limit Exceeded

Solution code:
q1=list(map(int,input().split(" ")))
a1=list(map(int,input().split(" ")))

sumsum=0
for i in range(q1[0]-q1[1]+1):
    sum1=sum(a1[i:i+q1[1]])
    if(sumsum<sum1):
        sumsum=sum1
sumsum+=q1[1]
print(sumsum/2)

Submission status: Time Limit Exceeded

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

max_ = 0
for i in range(n-a+1):
    max_ = max(max_,(sum(p[i:i+a]) / 2 + 0.5*a))
print(max_)