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()))
  
x = 0
m = 0

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

ans = 0    
for i in range(x, x+k):
  ans += (p[i] + 1) / 2

print("{0:.12f}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
list = input().split()
expectation = []
for i in range(len(list)):
  expectation.append((1+int(list[i]))/2)
max = 0
for i in range(n-k+1):
  tmp = sum(expectation[i:i+k])
  if tmp > max:
    max = tmp
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 calc_E(prob):

    E = sum([i for i in range(1, prob+1)]) / prob
    return E

def main(N, K, list_p):
    
    list_E = list(map(calc_E, list_p))
    max_E  = sum(list_E[0:K])
    prev_E = sum(list_E[0:K])

    for i in range(1, N-K+1):
        tmpE   = prev_E - list_E[i-1] + list_E[i-1+K]
        max_E  = max(max_E, tmpE)
        prev_E = tmpE

    return max_E
        


if __name__ == "__main__":

    [N, K] = list(map(int, input().split(' ')))
    list_p = list(map(int, input().split(' ')))

    answer = main(N, K, list_p)
    print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = 0
Elist = []
for p in P[0:K]:
    plist = list(range(1, p+1))
    Elist.append(sum(plist) / len(plist))
E = sum(Elist)
oldE = E
count = K - 1
for p in P[K:]:
    count += 1
    plist = list(range(1, p+1))
    Elist.append(sum(plist) / len(plist))
    E -= Elist[count - K]
    E += Elist[count]
    if oldE <= E:
        oldE = E
print(oldE)

Submission status: Time Limit Exceeded

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

#dice = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
import numpy as np
dice = np.array(p)
max = 0
for i in range(len(dice) - (int(K)-1)):
    d = dice[i:i+int(K)]
    sum = np.sum(d)
    if max < np.max([max, sum]):
        max = np.max([max, sum])
        index = i

sum = np.sum(dice[index:index+int(K)])
sum += int(K)
print(sum / 2)

Submission status: Time Limit Exceeded

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

print(max)

Submission status: Time Limit Exceeded

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

pos = 0
saidai = 0
for i in range(N-K+1):
  temp = sum(p[i:i+K])
  if saidai < temp:
    saidai = temp
    pos = i
    
kitaichi = 0
for i in range(K):
  temp = (p[pos+i]+1)*p[pos+i]/2
  kitaichi = kitaichi + float(temp/p[pos+i])
  
print('{:.12f}'.format(kitaichi))

Submission status: Time Limit Exceeded

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

l = []
m = []

s = 0
 
for i in range(n):
  l.append(((1+p[i])*p[i]/2)/p[i])

for i in range(n-k+1):
  for j in range(k):
    s += l[j+i]
  m.append(s)
  s=0

print(max(m))

Submission status: Time Limit Exceeded

Solution code:
numbers = input().split()
n = int(numbers[0])
k = int(numbers[1])
dices_input = input().split()
dices = []
for i in dices_input:
    dices.append((int(i)+1)*0.5)

expected = []
for j in range(n-k+1):
    ex = 0
    for x in range(k):
        ex += dices[j + x]
    expected.append(ex)
print(max(expected))

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def expected_value(n):
    ans = 0

    for i in range(1, n+1):
        ans += i/n

    # eprint(ans)
    return ans

def main():
    n, k = map(int, input().split())
    Ps = list(map(int, input().split()))
    
    Cs = [0]*n
    for i in range(n):
        if i == 0:
            Cs[i] = Ps[i]
        else:
            Cs[i] = Cs[i-1] + Ps[i]
    
    Ds = list()
    mi = -10**9
    mix = 0
    for i in range(n-k+1):
        if i == 0:
            Ds.append(Cs[i+k-1])
        else:
            Ds.append(Cs[i+k-1] - Cs[i-1])

        if Ds[i] > mi:
            mi = Ds[i]
            mix = i

    
    #mix ~ mix+kまでの
    v = int()
    for i in range(k):
        v += expected_value(Ps[mix+i])
        
    print(v)

    return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# N個のサイコロ。隣接するK個のサイコロを選んで振る
N, K = map(int, input().split())

# 左から i 番目のサイコロは 1 から pi までの pi 種類の目がそれぞれ等確率で出る
P = list(map(int, input().split()))

max_list = 0
for i in range(K-1, N+1):
    new_list = P[i-K:i]
    if i == K - 1:
        max_list = new_list
    else:
        if sum(new_list) > sum(max_list):
            max_list = new_list

result = 0
for n in max_list:
    result += sum([n for n in range(1, n+1)]) / n

print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

p_0 = np.hstack((p, np.array([0] * (K-1))))

ps = [np.roll(p_0,i) for i in range(K)]

s = sum(ps)
max = max(s)

print((max + K) / 2)

Submission status: Time Limit Exceeded

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

max_e=0
for i in range(N-(K-1)):
  v=p[i:K+i]
  smax=sum(v)
  e=(K+smax)/2

  if max_e<e:
    max_e=e
    
print(max_e)

Submission status: Time Limit Exceeded

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

for i in range(0, N-K+1):
    for j in range(i, i+K):
        temp += (p[j]+1)/2
    if max_val < temp:
        max_val = temp
        index = i
    temp = 0

print(max_val)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

tmp = p[ind:ind+K]

print((sum(tmp)+K)*0.5 )

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

b=0

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

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache


def main(n, k, p: list):
    ans = 0

    for i in range(n - k + 1):
        t = 0

        for j in p[i : i + k]:
            t = calc(j, t)

        ans = max(ans, t)

    print("{:06f}".format(ans))


@lru_cache(maxsize=1000)
def calc(j, t):
    for _k in range(1, j + 1):
        t += _k * (1 / j)
    return t


if __name__ == "__main__":
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    main(n, k, p)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

n, k = map(int, input().split())
ps = list(map(int, input().split()))
ps = [(p + 1)/2 for p in ps]
# print(ps)

d = deque()
vmax = 0
for p in ps:

    if len(d) == k:
        old = d.popleft()
        new = p
        d.append(new)
        if sum(d) > vmax:
            vmax = sum(d)
    else:
        d.append(p)
        vmax += p
    # print(vmax, d)

print(vmax)

Submission status: Time Limit Exceeded

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

def expect(pi):
    sum = 0.0
    for i in range(1, pi+1):
        sum += float(i)
    return sum/float(pi)

def solve1(N: int, K: int, p: "List[int]"):

    ans = 0.0
    for n in range(N-K+1):
        sum_exp = 0.0
        for e in range(K):
            sum_exp += expect(p[n+e])
        if ans < sum_exp:
            ans = sum_exp
    print(ans)

    return

def solve2(N: int, K: int, p: "List[int]"):

    max_int = 0
    max_idx = 0
    for n in range(N-K+1):
        sum_int = 0
        for e in range(K):
            sum_int += p[n+e]
        if max_int < sum_int:
            max_int = sum_int
            max_idx = n

    sum_exp = 0.0
    for e in range(K):
        sum_exp += expect(p[max_idx+e])
    print(sum_exp)

    return

def solve(N: int, K: int, p: "List[int]"):

    sum_int = 0
    for e in range(K):
        sum_int += p[e]

    max_int = sum_int
    max_idx = 0
    for n in range(1, N-K+1):
        sum_int -= p[n-1]
        sum_int += p[n+K-1]
        #print(p[n-1], p[n+K-1])
        if max_int < sum_int:
            max_int = sum_int
            max_idx = n

    sum_exp = 0.0
    for e in range(K):
        sum_exp += expect(p[max_idx+e])
    print(sum_exp)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
input_line = [int(i) for i in input().split(" ")]
k = input_line[1]

input_line = [int(i) for i in input().split(" ")]

for i, value in enumerate(input_line):
    input_line[i] = (value + 1) / 2

max_excepted_value = 0
for i in range(len(input_line) - k + 1):
    sum_excepted_value = sum(input_line[i: i+ k])
    if max_excepted_value < sum_excepted_value:
        max_excepted_value = sum_excepted_value
print(max_excepted_value)

Submission status: Time Limit Exceeded

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

ex_value_list = []
for i in range(0,int(n-k+1)):
  ex_value = 0
  for j in range(0, k):
    x = p_list[i+j]           
    ex_value += (x+1)/2
  ex_value_list.append(ex_value)
               
print(max(ex_value_list))

Submission status: Time Limit Exceeded

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

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
max_ans = ans
max_index = 0

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    if max_ans < ans:
        max_ans = ans
        max_index = i+1

ans = 0
for i in range(k):
    for j in range(p[max_index+i]):
        ans += (1/p[max_index+i]*(j+1))
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# D - Dice in Line
N, K = tuple(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
a = list()
for i in range(N - K + 1):
    sum = 0
    for j in range(K):
        sum += (1 + p[i+j]) / 2
    a.append(sum)

print(max(a))

Submission status: Time Limit Exceeded

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

max_val = 0
max_idx = 0
for i in range(1,N-K+2):
  tmp = sum(p[i-1:i-1+K])
  if tmp > max_val:
    max_val = tmp
    max_idx = i

expect = 0.0
for i in range(max_idx, max_idx+K):
  tmp = 0.0
  for j in range(1,p[i-1]+1):
    tmp += j
  expect += tmp/p[i-1]
print(expect)

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
obj_list=[0,0]
for i, a in enumerate(p):
    if sum(obj_list)< sum(p[i:i+K]):
        obj_list = p[i:i+K]
ans = 0
for i in obj_list:
    a = sum(range(0,i+1,1))/i
    ans += a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():

    from itertools import accumulate

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

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

    p_cum = [0] + list(accumulate(p))

    ma = 0
    ind = 0
    for i in range(k, n+1):
        if ma < p_cum[i] - p_cum[i-k]:
            ma = p_cum[i] - p_cum[i-k]
            ind = i

    x = p[ind-k:ind]

    print(sum(e(d) for d in x))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
for i in range(q[0]-q[1]+1):
  k=0
  for j in range(q[1]):
    k+=w[i+j]
  if a<k:
    a=k
    memo=i
print((a+q[1])/2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def calc_exp(n):
    s = sum(list(range(1,n+1)))
    return s/n

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 = tuple(map(int, input().split()))

prev = 0
ind = 0
for i in range(n - k + 1):
    nex =  sum(p[i:i+k])

    if prev < nex:
        prev = nex
        ind = i

total = 0
for i in range(ind, ind + k):
    total += (1 + p[i]) * (p[i] / 2) / p[i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
L = [int(x) for x in input().split()]
S = [0]
for x in range(N-K+1):
    NL = L[0+x:K+x]
    if sum(NL) > sum(S):
        S = NL
ANS = 0
for x in S:
    LL = [n for n in range(1,x+1)]
    ANS += sum([1/len(LL)*x for x in LL])
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, K = mulinputs()
# ps = list(mulinputs())
memo = dict()
def kitaiti(s):
    if s in memo.keys():
        return memo[s]
    n = int(s)
    k = ((n*(1+n))>>1)/int(n)
    memo[s] = k
    return k
ps = list(map(kitaiti, input().split()))

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


# 出力
print(ans)

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+=sum(range(1,i+1))/i
    b2=max(b1,b2)
    b1=0
    if d+_==len(a):
        break
    _+=1
print(b2)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
M=0
M_IND=0
for i in range(len(L)-(K-1)):
  tmp = L[i]
  for j in range(i+1, i+K):
    tmp += L[j]
  #print(tmp)
  if M < tmp:
    M = tmp
    M_IND=i
#print(M_IND)
#for k in range(L[M_IND,M_IND+K])
ANS=0
for i in L[M_IND:M_IND+K]:
  #print(i)
  ex = 0
  p = 1/i
  for x in range(i+1):
      px = p*x
      ex += px
  ANS += ex
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
i = input().split()
n = int(i[0])
nannko = int(i[1])
i2 = input().split()
nAr = [int(s) for s in i2]

max = 0
for j in range(n - nannko + 1):
    li = nAr[j:j+nannko]
    sum = 0
    for k in range(len(li)):
        sum += (li[k] + 1)/2
        if (sum > max):
        	max = sum
print(max)

Submission status: Time Limit Exceeded

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

c = N - K + 1
dp = [0 for _ in range(c)]

for i in range(c):
    dp[i] = sum(P[i:i + K])

n = dp.index(max(dp))

pp = sum(map(lambda x: sum(range(1, int(x) + 1)) / x, P[n: n + K]))

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
EV_p_list = [0] * len(p_list)

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

max_EV = 0
for i in range(N - K + 1):
  tmp = 0
  for j in range(K):
    tmp += EV_p_list[i + j]
  
  if tmp >= max_EV:
    max_EV = tmp

print(max_EV)

Submission status: Time Limit Exceeded

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

def kitaiti(n , k , p):

    ans = 0
#    kitai = [0]*n

#    for i in range(n):
#        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n - k + 1):
        count = 0
        for w in range(i , i + k):
#            count += kitai[w]
            count += tasu(p[w]) / p[w]

        ans = max(ans , count)

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

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

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

p_a = 0
for i in range(n-k+1):
    p_r = p[i:i+k]
    p_b = 0
    for j in p_r:
        if j == 1:
            p_b += 1
        else:
            p_b += (j + 1) / 2
    if p_b > p_a:
        p_a = p_b
print(p_a)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def main():
    N, K = map(int, input().split(" "))
    P = np.array(list(map(int, input().split(" "))))

    e = (P + 1) / 2

    t = np.ones((K))

    print(np.max(
        np.convolve(
            e,
            t
        )
    ))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

max_index = 0
max_sum = 0
for i in range(len(P)-(K-1)):
    sum_P = sum(P[i:i+K])
    if sum_P > max_sum:
        max_sum = sum_P
        max_index = i

#print(max_sum)
#print(max_index)

# 隣接したK個のリスト
kk = P[max_index: max_index+K]

# kの期待値を計算
max_kk = max(kk)
dp = [0]
for i in range(1, max_kk+1):
    dp.append(dp[i-1] + i)
#print(dp)

ans = 0
for k in kk:
    ans += dp[k]/k

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    maxi = 0
    ans = 0
    l = []
    for i in range(N-M+1):
        s = sum(A[i:M+i])        
        if maxi < s:
            maxi = s
            l = A[i:M+i]

    r = [(i/2 + 0.5) for i in l]
    return sum(r)

print(solve())

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
diceList=[(int(x)+1)/2 for x in input().split()]
 
maxNum=0
st=0
for i in range(N-K+1):
  for j in range(K):
    st+=diceList[i+j]
  if(st>=maxNum):
    maxNum=st
  else:
    pass
  st=0
print(maxNum)

Submission status: Time Limit Exceeded

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

k = [0]*N

"""
def kitaiti(n):
    sum = 0
    for i in range(1,n+1):
        sum += i
    return sum / n
""" 
def kitaiti(n):
    return 0.5*n + 0.5

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

ans = 0
for i in range(K):
    ans += kitaiti(p[index + i])
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n[0]):
    p[i]=(p[i]+1)/2
"""
max_sum= 0
for i in range(n[0] - n[1] + 1):
    chunk = numbers[i:i + 13]  # i, i + 1, ..., i + 12 番目の13個の数字を取り出す。
    prod = functools.reduce(operator.mul, chunk, 1)  # 部分リストのすべての値の積
    max_prod = max(max_prod, prod)  # 最大値更新    
"""    
    
max_sum=0
for i in range(n[0]-n[1]+2):
    max_sum=max(max_sum,sum(p[i:i+n[1]]))
print(max_sum)

Submission status: Time Limit Exceeded

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

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

for l in range(0,K):
     m[l] = (1+m[l])/2
n = sum(m)
print(n)

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N, K = int(NK[0]), int(NK[1])
#lis_p = list(map(lambda x: int(x), input().split()))
lis_exp = list(map(lambda x: (int(x)+1)/2, input().split()))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

Submission status: Time Limit Exceeded

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

# １からNまでの値をもつサイコロを振ったときの期待値
def ex(x:int):
    return (x*(x+1)/2)/x

# 期待値のリストを作る
kitaichi = []
for i in range(len(p)):
    kitaichi.append(ex(p[i]))

# 期待値の最大値のリストを作る
kitaichi_goukei = []
for i in range(len(kitaichi)-k+1):
    kitaichi_goukei.append(sum(kitaichi[i:i+k]))

print (max(kitaichi_goukei))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-

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


x = 0
for i in range(k-1, n):
	s = 0
	tmp = []
	for j in range(i-(k-1), i+1):
		tmp.append(p[j])
		s += p[j]
	if x < s:
		x = s
		y = tmp

ans = 0
for i in y:
	a = 0
	for j in range(1, i+1):
		a += j
	ans += a / i

print(ans)

Submission status: Time Limit Exceeded

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

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

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
	else:
		summ = summ - expectedval(plist(i - 1)) + expectedval(plist(i + k))
	maxval = max(summ, maxval)

print(maxval)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    pl = [(K + sum(P[i:i+K])) * 0.5 for i in range(N-K+1)]
    ans = max(pl)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#154 d
def kitaichi(x):
    return (x+1)/2

n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(n-k+1):
    s=0
    for j in range(k):
        s+=kitaichi(p[i+j])
    if s>=ans:
        ans=s
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []
m = []
s = []
j = 0
for i in range(1, 1001):
    j += i
    s.append(j)
c = 0
for i in range(n-k+1):
    ans = 0
    a = p[i:i+k]
    for b in a:
        ans += s[b-1]/b
    l.append(ans)
    c = max(c, ans)
print(c)

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()))
t=0


for i in range(N-K+1):
  if sum(p[i:i+K])>t:
    t=sum(p[i:i+K])
    
print((K+t)/2)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc154/tasks/abc154_d
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = input().split()
for i in range(N):
  p[i] = int(p[i])
E = []
A = []
for k in range(N):
  E.append(0)
  for i in range(1,p[k]+1):
    E[k] = E[k]+i/p[k]
for i in range(N-K+1):
  kitai = 0
  for k in range(K):
    kitai = kitai + E[k+i]
  A.append(kitai)
print(max(A))

Submission status: Time Limit Exceeded

Solution code:


def dice(p):
    sum = 0
    for i in range(1,p+1):
        sum += i/p
    return sum

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

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

res = 0
for i in l:
    res += dice(i)

print(res)

Submission status: Time Limit Exceeded

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

exp={}

ans=0
cnt=0
for i in range(1,1001):
    sum=0
    for j in range(1,i+1):
        sum+=j
    exp[i]=sum/i

while cnt<=n-k:
    tmp=0
    for i in range(k):
        tmp+=exp[p[i+cnt]]
    if ans < tmp:
        ans=tmp
    cnt += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

print(max_sum)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
p =list(map(int,input().split()))
pm = 0
for i in range(len(p) - k + 1):
  tmp = 0
  for j in range(k):
    tmp += p[i+j]
  pm = tmp if (tmp >= pm) else pm
ans = (pm + k) / 2
print(ans)

Submission status: Time Limit Exceeded

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

    max_tmp = [0] * K
    for i in range(len(P) - K + 1):
        tmp = P[i: i + K]
        if sum(max_tmp) < sum(tmp):
            max_tmp = tmp

    ans = 0
    for number in max_tmp:
        dice = list(range(1, number + 1))
        for x in dice:
            p = 1 / number
            px = p * x
            ans += px

    print(ans)


resolve()

Submission status: Time Limit Exceeded

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

exp = 0
for idx in range(n - (k - 1)):
    tmp = 0
    for num in range(k):
        tmp +=  (pi[idx + num] + 1)
    if exp < tmp:
        exp = tmp

print(exp / 2)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
n, k = map(int, input().split())
P = deque(map(int, input().split()))

s_max = 0
popped = 0
P_max = deque([])
for i in range(k):
    popped = P.popleft()
    P_max.append(popped)
    s_max += popped
s = s_max
# print(s)
P_extracted = deque(list(P_max))
while P != deque([]):
    # print(P_extracted, P, P_max)
    s -= P_extracted.popleft()
    popped = P.popleft()
    s += popped
    # print(s)

    # P_extracted.popleft()
    P_extracted.append(popped)
    # print(P_extracted)
    if s_max < s:
        s_max = s
        P_max = deque(list(P_extracted))
        # print(s_max, P_max)

# print(s_max, P_max)
e = 0
for i in P_max:
    tmp = 0
    for j in range(1, i+1):
        tmp += j / i
    # print(tmp)
    e += tmp
print(e)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
l = list()
for i in range(len(li)):
    j = i + k
    temp_li = li[i:j]
    s=  sum(temp_li)
    temp_li.insert(0, s)
    t = tuple(temp_li)
    l.append(t)


l.sort(reverse=True)
ans_li = list(l[0])
ans_li.pop(0)

ans = 0
for i in ans_li:
    s = 0
    for j in range(1, i+1):
        s += j
    ans = ans + (s / i)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = input().split()
b = input().split()

exlist = []

for i in range(int(a[0])):
    sum = 0
    for j in range(int(b[i])+1):
        sum += j
    exlist.append(sum/int(b[i]))

ans = 0

for i in range(int(a[0])-int(a[1])+1):
    sum = 0
    for j in range(int(a[1])):
        sum += exlist[i+j]
    if ans < sum:
        ans = sum

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

E = (P + 1) / 2

ans = 0
for i in range(N-K+1):
  tmp = np.sum(E[i:i+K])
  if tmp > ans:
    ans = tmp

print(ans)

Submission status: Time Limit Exceeded

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

e_nums = [(i+1)/2 for i in nums]

sum_e = [sum(e_nums[i:i+k]) for i in range(n) if i+k <= n]

print(max(sum_e))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

f = lambda x: (x+1)/2
numpy_frompyfunc = np.frompyfunc(f, 1, 1)

a = numpy_frompyfunc(np_P)
v = np.ones(K)

print(max(list(np.convolve(a,v, mode='same'))))

Submission status: Time Limit Exceeded

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

maxlist = sum(numlist[0:K])
max_num = 0
for i in range(N-K+1):
  a = sum(numlist[i:i+K])
  if a >= maxlist:
    maxlist = a
    max_num = i

definelist = numlist[max_num:max_num+K]
expected = 0
for j in definelist:
  dice = list(range(1, j+1))
  p = 1/len(dice)
  expected += sum(p*x for x in dice)

print(expected)