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

num = []
tmp = 0
for n in P:
    tmp = 0
    for i in range(1, n+1):
        tmp += i
    tmp = tmp/n
    num.append(tmp)

s = []

for n in range(len(num)):
    s.append(sum(num[n:n+K]))

result = sorted(s)[-1]
print(result)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
ans = sum(P[:K])
for i in range(1, N-K+1):
    e = sum(P[i:i+K])
    if ans < e:
        ans = e
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for i in range(N):
    e[i] = np.sum(np.arange(1, P[i]+1)) / P[i]

# !! not fast enough with native sliding window impl
# ret = np.sum(e[:K-1])
# curr = ret
# for i in range(K - 1, N):
#     curr += e[i]
#     ret = max(ret, curr)
#     curr -= e[i - K + 1]


# !! technically not an efficient sliding window
ret = 0
for i in range(N - K + 1):
    ret = max(ret, np.sum(e[i:i+K]))

print(ret)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = []
for i in range(a - b + 1):
	h = 0
	for j in range(b):
		h += c[i + j]
	d.append(h)
e = 0
g = d.index(max(d))
for i in range(b):
	f = c[i + g]
	d = 0
	for j in range(f):
		d += (j + 1)
	e += d / f
print(e)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(p+1)/2 for p in p_list]
max_nums = 0
max_targets = []
for j in range(0, len(e_list)-k+1):
  targets = [e_list[j+m] for m in range(k)]
  t_sum = sum(targets)
  if t_sum >= max_nums:
    max_nums = t_sum
    max_targets = targets
print(sum(max_targets))

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
q =[]
ans = 0

for p in [int(n) for n in input().split()]:
    if len(q) < K:
        q.append((p-1)/2+1)
    else:
        m = sum(q)
        if m > ans:
            ans = m
        q.append((p-1)/2+1)
        q.pop(0)
print(ans if ans>sum(q) else sum(q))

Submission status: Time Limit Exceeded

Solution code:
size, count = list(map(int,input().split()))
dices = list(map(int,input().split()))

max_num = 0
d_set = dices[0:count]
max_sum = sum(d_set)

for num,d in enumerate(dices[count:]):
    d_set.pop(0)
    d_set.append(d)
    now_sum = sum(d_set)
    if max_sum < now_sum:
        max_sum = now_sum
        max_num = num+1

max_set = dices[max_num: max_num+count]
kitai = sum([(d+1)/2 for d in max_set])
print(kitai)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
P =  [int(n) for n in input().split()]
q =[]
ans = 0

for p in P:
    if len(q) < K:
        q.append((p-1)/2+1)
    else:
        m = sum(q)
        if m > ans:
            ans = m
        q.append((p-1)/2+1)
        q.pop(0)
print(ans if ans>sum(q) else sum(q))

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(n for n in range(1, P[i] + 1)) / P[i]

ret = sum(e[i] for i in range(K - 1))
curr = ret
for i in range(K - 1, N):
    curr += e[i]
    ret = max(ret, curr)
    curr -= e[i - K + 1]

print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(n) for n in input().split()]
P =  [int(n) for n in input().split()]
o = {}
q =[]
ans = 0

def e(x):
    if x in o: return o[x]
    o[x] = sum([(j/x) for j in range(1,x+1)])
    return o[x]

for p in P:
    if len(q) < K:
        q.append(e(p))
    else:
        m = sum(q)
        if m > ans:
            ans = m
        q.append(e(p))
        q.pop(0)
print(ans if ans>sum(q) else sum(q))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
total = 0
if N != K:
  for i in range(N-K+1):
    tmp = sum(p[i:i+K])
    if tmp > total:
      total = tmp
else:
  total = sum(p)
total = K + total
print(total/2)

Submission status: Time Limit Exceeded

Solution code:
import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
m = 0
for i in l[:]:
    if len(el) != k:
        el.append((1+i)/2)
        ans = sum(el)
        m = ans
    else:
        el.append((1+i)/2)
        m = m-m_e+el[-1]
        ans = m if m>ans else ans
    m_e = el[0]
print(ans)

Submission status: Time Limit Exceeded

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

max_p = 0

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

ex = (max_p - K + 2)/2

print(ex + K - 1)

Submission status: Time Limit Exceeded

Solution code:
import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
for i in l[:]:
    el.append((1+i)/2)
    ans = sum(el) if sum(el)>ans else ans
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline #入力高速化
N,K = [int(i) for i in input().rstrip().split(' ')]
A = [int(i) for i in input().rstrip().split(' ')]

m = (0,0)
for i,a in enumerate(A):
    if i < K-1:
        continue
    s = sum(A[i-K+1:i+1])
    if s > m[0]:
        m = (s,i)
r = sum([(a+1)/2 for a in A[m[1]-K+1:m[1]+1] ])
print(r)

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(i) for i in input().rstrip().split(' ')]
A = [int(i) for i in input().rstrip().split(' ')]

m = (0,0)
for i,a in enumerate(A):
    if i < K-1:
        continue
    s = sum(A[i-K+1:i+1])
    if s > m[0]:
        m = (s,i)
r = sum([(a+1)/2 for a in A[m[1]-K+1:m[1]+1] ])
print(r)

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(i) for i in input().rstrip().split(' ')]
A = [int(i) for i in input().rstrip().split(' ')]
L = [sum(A[i:i+K]) for i in range(N-K+1)]
m = L.index(max(L))
r = 0
for i in A[m:m+K]:
    r += (i+1)/2
print(r)

Submission status: Time Limit Exceeded

Solution code:
#ABC154C

n, k = list(map(int,input().split()))
p = list(((int(x)+1)/2) for x in input().split())

ave = 0
j = 0

for i in range(n-k+1):
    temp = p[i:i+k]
    _ave = sum(temp)
    if _ave>=ave:
        ave = _ave
print(ave)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(0,N-K+1):
  tmp  = 0
  for j in range(i,i+K):
    tmp += ((1+P[j])*P[j]/2)/P[j]

  ans = max(ans,tmp)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K = [int(i) for i in input().rstrip().split(' ')]
A = [int(i) for i in input().rstrip().split(' ')]
P = [(i+1)/2 for i in A]
L = [sum(P[i:i+K]) for i in range(N-K+1)]
print(max(L))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#ABC154C

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

ave = 0
j = 0

for i in range(n-2):
    temp = p[i:i+k]
    _ave = (sum(temp))/k
    if _ave>=ave:
        ave = _ave
        j = i

import numpy as np
d = np.array(p[j:j+k])
kitai = sum((1+d))/2

# 計算量がO(K)を再計算しているため NG
# kitai = 0
# for x in p[j:j+k]:
#     kitai += sum(range(1,x+1))/x

print(kitai)

Submission status: Time Limit Exceeded

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

m = 0
for i in range(n-k+1):
  if m < sum(dp[i:i+k]):
    m = sum(dp[i:i+k])
print(m/2)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n-k+1):
    sums = l[i:i+k]
    ans = max(ans,sum(sums)/2)
    
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
ls = list(map(int, input().split()))
a = [0.5*(ls[i]+1) for i in range(0, k)]
m = sum(a)
for i in range(1,n-k+1):
    b = [0.5 * (ls[i]+1) for i in range(i, i+k)]
    if sum(b) > m:
        m = sum(b)
print(m)

Submission status: Time Limit Exceeded

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

total = [0]
for i in range(1, 20000):
    total.append(total[i-1]+i)

for i in range(n-k+1):
    tmp = sum(p[i:i+k])
    if tmp > max_p:
        max_p = tmp
        ans_index = i
ans = 0
for i in range(k):
    ans += total[p[ans_index+i]] / p[ans_index+i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = []
for i in range(N):
    e = (p[i] + 1) / 2 
    tmp_ans += e
    queue.append(e)
    if len(queue) > K:
        tmp_ans = tmp_ans - queue.pop(0)
    max_ans = max(max_ans, tmp_ans)
print(max_ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = []
for i in range(N):
    e = (p[i] + 1) / 2 
    queue.append(e)
    if len(queue) > K:
        tmp_ans = tmp_ans - queue.pop(0) + e
    else:
        tmp_ans += e
    max_ans = max(max_ans, tmp_ans)
print(max_ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = []
for i in range(N):
    e = (p[i] + 1) / 2 
    queue.append(e)
    if len(queue) > K:
        tmp_ans = tmp_ans - queue[0] + e
        queue.pop(0)
    else:
        tmp_ans += e
    max_ans = max(max_ans, tmp_ans)
print(max_ans)

Submission status: Time Limit Exceeded

Solution code:
#ABC154C

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

ave = 0
j = 0
for i in range(n-2):
    temp = p[i:i+k]
    _ave = (sum(temp))/k
    if _ave>=ave:
        ave = _ave
        j = i

kitai = 0
for x in p[j:j+k]:
    kitai += sum(range(1,x+1))/x

print(kitai)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

kitai = list(map(lambda x: (x+1)/2, p))

gokei = 0

for i in range(n-k+1):
    wa = sum(kitai[i:i+k])
    if gokei < wa:
        gokei = wa

print(gokei)

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,k = LI()
p = LI()

def a(num):
    return 0.5*num + 0.5

ans = 0
for i in range(n-k+1):
    ans = max(ans,sum([a(j) for j in 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()))
l = [0 for i in range(n)]
ans = 0
cnt = 0
for i in range(n):
  l[i] = p[i]*(p[i]+1)/(2*p[i])
if n == k:
  for i in range(k):
    ans += l[i]
else:
  for i in range(n-k+1):
    cnt = sum(l[i:i+k])
    if cnt > ans:
      ans = cnt
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p = list(map(lambda n: 0.5*(n-1)+1, p))

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

Submission status: Time Limit Exceeded

Solution code:
L = []
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p = list(map(lambda n: 0.5*(n-1)+1, p))

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

Submission status: Time Limit Exceeded

Solution code:
#!python3.4.3

def divid(x):
    return (int(x) / 2) + 0.5

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

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

Submission status: Time Limit Exceeded

Solution code:
#!python3.4.3

def divid(x):
    return (x / 2) + 0.5

n, k =  map(int, input().split(' '))
p = list(map(int, input().split(' ')))
 
max_ = 0
 
for i in range(0, n-k+1):
    temp = sum(map(divid, p[i:i+k]))
    if max_ < temp:
        max_ = temp
    
print(max_)

Submission status: Time Limit Exceeded

Solution code:
#!python3.4.3

def divid(x):
    return (x / 2) + 0.5

n, k =  map(int, input().split(' '))
p = list(map(int, input().split(' ')))
 
max_ = 0
 
for i in range(n):
    temp = p[i:i+k]
    if len(temp) < k:
        break
    
    result = sum(map(divid, temp))
    if max_ < result:
        max_ = result
    
print(max_)

Submission status: Time Limit Exceeded

Solution code:
#!python3.4.3

def divid(x):
    return (x / 2) + 0.5

n, k =  map(int, input().split(' '))
p = list(map(int, input().split(' ')))
 
max_ = [0] 
 
for i in range(n):
    temp = p[i:i+k]
    if len(temp) < k:
        break
    if sum(max_) < sum(temp):
        max_ = temp
    
result = list(map(divid, max_))
print(sum(result))

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

max_exp = 0
for i in range(N-K+1):
    s = sum(P_exp[i:i+K])
    if s > max_exp: max_exp = s
    
print(max_exp)

Submission status: Time Limit Exceeded

Solution code:
def calc_exp(n):
    return (1+n)/2

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

P_exp = [calc_exp(p) for p in P]

max_exp = 0
for i in range(N-K+1):
    s = sum(P_exp[i:i+K])
    if s > max_exp: max_exp = s
    
print(max_exp)

Submission status: Time Limit Exceeded

Solution code:
def calc_exp(n):
    return (1+n)/2

exp_list = [0]
for i in range(1,200001):
    exp_list.append(i)

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

P_exp = [calc_exp(p) for p in P]

max_exp = 0
for i in range(N-K+1):
    s = sum(P_exp[i:i+K])
    if s > max_exp: max_exp = s
    
print(max_exp)

Submission status: Time Limit Exceeded

Solution code:
def calc_exp(n):
    return (1+n)/2

exp_list = [0]
for i in range(1,200001):
    exp_list.append(i)

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

for i,p in enumerate(P):
    P[i] = calc_exp(p)
    
max_exp = 0
for i in range(N-K+1):
    s = sum(P[i:i+K])
    if s > max_exp: max_exp = s
    
print(max_exp)

Submission status: Time Limit Exceeded

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

def calcE(l):
  expect = 0
  for i in range(len(l)):
    expect += ( (l[i]*(l[i]+1) / 2 ) / l[i] )
  return expect

maxl = list()
for j in range(n-k+1):
  if sum(P[j:j+k]) > sum(maxl):
    maxl = P[j:j+k]

print(calcE(maxl))

Submission status: Time Limit Exceeded

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

kitaichi = [(1+v)/2 for v in c]

score = [sum(kitaichi[i:i+k]) for i,v in enumerate(kitaichi) if i+k-1 != len(kitaichi)]
print(max(score))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
li = list(map(int, input().split()))
r = []
ans = []
for x in li:
    r += [(x-1)*(1/2)+1]
    ans += [sum(r[-K:])]
print(max(ans))

Submission status: Time Limit Exceeded

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

exes = list()
for maxe in maxes:
    exes.append((maxe+1)/2)

max_exes = 0
for i in range(len(exes) - numbers[1] + 1):
    temp = exes[i]
    for j in range(1, numbers[1]):
        temp += exes[i + j]
    if max_exes < temp:
        max_exes = temp
ans = '{:.12f}'.format(max_exes)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
lst = [int(x)+1 for x in input().split()]
a = 0
for i in range(N-K+1):
    if sum(lst[i:i+K]) > a:
        a = sum(lst[i:i+K])

print(a/2)

Submission status: Time Limit Exceeded

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

exes = list()
for maxe in maxes:
    exes.append((maxe+1)/2)

max_exes = list()
for i in range(len(exes) - numbers[1] + 1):
    temp = exes[i]
    for j in range(1, numbers[1]):
        temp += exes[i + j]
    max_exes.append(temp)
ans = '{:.12f}'.format(max(max_exes))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
N, K = map(int, input().split())
li = list(map(int, input().split()))
r = []
ans = []
for x in li:
    a = list(itertools.accumulate(list(range(1,x+1))))
    b = a[-1] / x
    r += [b]
    ans += [sum(r[-K:])]

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

n,k = input().split()
p = input().split()

n = int(n)
k = int(k)

ex =0
ext = []
ext2 = []
for f in range(n):
    xs = list(range(1,int(p[f])+1))
    xs = sum(xs)*1/int(p[f])
    ext.append(xs)

ext2.append(ext[0])
for i in range(1,n):
    ext2.append(ext2[i-1]+ext[i])

ex = ext2[k-1]
for j in range(1,n-k+1):
    ext3 =ext2[j+k-1]-ext2[j-1]
    if ext3 > ex: ex = ext3

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

Submission status: Time Limit Exceeded

Solution code:
import math

n,k = input().split()
p = input().split()

n = int(n)
k = int(k)
p = [int(s) for s in p]

#print(p)

ex =0
ext = []
ext2 = []
for f in range(n):
    xs = list(range(1,p[f]+1))
    xs = sum(xs)*1/p[f]
    ext.append(xs)

ext2.append(ext[0])
for i in range(1,n):
    ext2.append(ext2[i-1]+ext[i])

ex = ext2[k-1]
for j in range(1,n-k+1):
    ext3 =ext2[j+k-1]-ext2[j-1]
    if ext3 > ex: ex = ext3

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

a = input()
N,K = a.split()
b = input()
pl = b.split()

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 1
        j = 0
        kitaiti = 0
        kari = 0
        if int(p) > 1000:
            print("1000以下を入れろｋｓ")
            break
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print("{:.12f}".format(kitaiti))

Submission status: Time Limit Exceeded

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

ev = [(a+1)/2 for a in A]
ans = 0
for i in range(len(A)-K+1):
  ans = max(ans, sum(ev[i:i+K]))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = None
s = None

for i in range(0, N - K + 1):
    s = 0

    for j in range(K):
        s += a[i+j] + 1

    if ans is None or ans < s:
        ans = s

print(ans/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = 0
for i in range(0, N-K+1):
    total = sum(P[i:i+K])
    if tmp < total:
        index = i
        tmp = total
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

n,k = input().split()
p = input().split()

n = int(n)
k = int(k)
p = [int(s) for s in p]

#print(p)

ex =0
ext = []
for f in range(n):
    xs = list(range(1,p[f]+1))
    #print(n,f, p[f],xs,sum(xs))
    xs = [s*1/p[f] for s in xs]
    #print(sum(xs))
    ext.append(sum(xs))
    #print(ext)
    
for i in range(n-k+1):

    txs = [ext[g] for g in range(i,i+k)]
    if sum(txs) > ex: ex = sum(txs)
print('{:.12f}'.format(ex))

Submission status: Time Limit Exceeded

Solution code:
# 期待値は1/2(n+1)
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp = 0
for i in range(n - k + 1):
    s = 0
    for j in range(k):
        s += p[i + j]
#        print(p[i+j], s)
    if exp <= s:
        exp = s
#        print(exp)
print((exp + k) / 2)

Submission status: Time Limit Exceeded

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

for i in range(0, N - K + 1):
    s = sum(a[i:i+K]) + K

    if ans is None or ans < s:
        ans = s

print(ans/2)

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

    max_t = 0
    for i in range(N-K+1):

        if max_t < sum(P[i:i+K]):
            max_t = sum(P[i:i+K])

    print((max_t + K) / 2)

main()

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
pi = list(map(int, input().split()))
index = []
for i in range(N-K+1):
    x = sum(pi[i:i+K])
    index.append(x)
max_index = index.index(max(index))
EX_max = 0
for i in range(max_index, max_index+K):
  EX_max += 1+(pi[i]-1)*0.5
print(EX_max)

Submission status: Time Limit Exceeded

Solution code:
c,d=map(int,input().split())
a=[int(x) for x in input().split()]
b1=0
b2=0
_=0
while True:
    for i in a[_:_+d]:
        b1+=(1+i)/2
    b2=max(b1,b2)
    b1=0
    if d+_==len(a):
        break
    _+=1
print(b2)

Submission status: Time Limit Exceeded

Solution code:
import sys
[N, K] = list(input().split())
P = list(input().split())
SUM_ = 0
for s in range(0,int(N)-int(K)+1):
    SUM = 0
    for d in range(0,int(K)):
        SUM += sum(range(1,int(P[d+s])+1))/int(P[d+s])
    if SUM >= SUM_:
        SUM_ = SUM
print(SUM_)
sys.stdout.flush

Submission status: Time Limit Exceeded

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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]
#    print(i, max_value, tmp_sum, P[i:i+K], "-", P[i], "+", P[i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += sum(list(range(1, P[i] + 1))) / P[i]
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys

def ev(v):
    return sum(range(1,v+1)) * 1.0/v

N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [ev(int(x)) for x in sys.stdin.readline().strip().split(" ")]

m = 0
i = 0
while K+i <= N:
    v = 0
    for k in range(K):
        #v += ev(p[i+k])
        v += p[i+k]
    if m < v:
        m = v
    i += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys

N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [int(x) for x in sys.stdin.readline().strip().split(" ")]

def ev(v):
    return sum(range(1,v+1)) * 1.0/v

m = 0
i = 0
while K+i <= N:
    v = 0
    for k in range(K):
        v += ev(p[i+k])
    if m < v:
        m = v
    i += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
num=list(map(int,input().split()))
nums=list(map(int, input().split()))
max=-1
if len(nums) == 1:
    max=(nums[0]+1)/2
elif num[1]==1:
    for i in nums:
        s=(i+1)/2
        if(s>max):
            max=s
else:
    sums=0
    a=[0]*num[1]
    for i in nums:
        c=(i+1)/2
        a.append(c)
        cc=a.pop(0)
        sums=sums-cc+c
        if(sums>max):
            max=sums
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

n,k = input().split()
p = input().split()

n = int(n)
k = int(k)
p = [int(s) for s in p]

#print(p)

ex =0
xs=[]

for i in range(n-k+1):
    ext = 0
    for f in range(k):
        xs = list(range(1,p[i+f]+1))
        #print(i,f, p[i+f],xs,sum(xs))
        xs = [s*1/p[i+f] for s in xs]
        #print(xs)
        ext +=sum(xs)
        #print(ext)
        
    if ext>ex:
        ex = ext
print('{:.12f}'.format(ex))

Submission status: Time Limit Exceeded

Solution code:
num=list(map(int,input().split()))
nums=list(map(int, input().split()))
max=-1
if num[1]==1:
    for i in nums:
        s=(i+1)/2
        if(s>max):
            max=s
else:
    a=[0]*num[1]
    for i in nums:
        a.append((i+1)/2)
        a.pop(0)
        s=sum(a)
        if(s>max):
            max=s
print(max)

Submission status: Time Limit Exceeded

Solution code:
def sigma(n):
    return sum([i for i in range(n+1)])
 
def main():
    N, K = map(int, input().split(' '))
    p = list(map(int, input().split(' ')))
 
    max_value = 0
    for i in range(N-K+1):
        sum_ = sum(p[i:i+K])
        if sum_ > max_value:
            max_value = sum_
            max_list = p[i:i+K]
 
    expected = 0
    for v in max_list:
        expected += sigma(v) / v
 
    print(expected)
 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def expected_value(arr):
    return [(1 + ele) / 2 for ele in arr]

n, k = [int(x) for x in input().split()]
arr = list(map(int,input().split()))
ev = expected_value(arr)

sum_tmp = [sum(arr[i:i+k]) for i in range(n - (k - 1))]
max_v = max(sum_tmp)
max_i = sum_tmp.index(max_v)
print(sum(ev[0:max_i+k]) - sum(ev[0:max_i]))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = 1+P
    kitaichi.append(kitai)
ans = []
for j in range((n-k)+1):
    a = sum(kitaichi[j:j+k])
    ans.append(a)
ans.sort(reverse=True)

print(ans[0]/2)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
ans,sums = 0,[0]*K
for i,pi in enumerate(map(int, input().split())):
  sums[i%K] = (pi+1)/2
  ans = max(ans, sum(sums))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n,k=map(int,input().split())
p=[ int(i) for i in input().split() ]
kitaichi_list=[]
cnt=kitaichi=wa=0

for i in p:
    kitaichi_list.append( (1+i)/2 )
    cnt+=1

    if cnt>k:
        del kitaichi_list[0]
        cnt-=1

    if cnt==k:
        kitaichi=sum(kitaichi_list)
        if kitaichi>=wa:
            wa=kitaichi

print(wa)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = (1+P)/2
    kitaichi.append(kitai)
ans = []
for j in range((n-k)+1):
    a = sum(kitaichi[j:j+k])
    ans.append(a)
ans.sort(reverse=True)

print(ans[0])

Submission status: Time Limit Exceeded

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

kitaichi_list = []

for i in p_list:
  kitaichi_list.append((1+i)/2)


j = sum(kitaichi_list[:K])
for i in range(1, N - K + 1):
  if sum(kitaichi_list[i:i+K]) > j:
    j = sum(kitaichi_list[i:i+K])

print(j)

Submission status: Time Limit Exceeded

Solution code:
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p2 = [p[i]*0.5 + 0.5 for i in range(N)]
max = 0

for i in range(N-K+1):
    tmp = sum(p2[i:i+K])
    if max < tmp:
        max = tmp
print('{:.12f}'.format(max))