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: Runtime Error

Solution code:
n,k,*p=map(int,open(0).read().split())
p.sort()
p.reverse()
l=p[:k]
print(l)
_sum=0
before=l[0]
rate=1
for i in range(len(l)):
    s=0
    if i!=0:
        if l[i]==before:
            rate*=2
        else:
            before=l[i]
            rate=1
        for j in range(1,l[i]+1):
            s+=j
        _sum+=s/l[i]/rate          
    else:
        for j in range(1,l[i]+1):
            s+=j
        _sum+=s/l[i]
print(_sum)

Submission status: Runtime Error

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

def su(n):
  return n*(n+1)/2

maxind=0
for i in range(n-k):
  if p[i+k] > p[i]:
    maxind = i
s = 0
for i in range(k):
  s += su(p[maxind+1+i])/p[maxind+1+i]
print(s)

Submission status: Runtime Error

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 = P_max.copy()
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 = P_extracted.copy()
        # print(s_max, P_max)

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

Submission status: Runtime Error

Solution code:
import pandas as pd





N,K = map(int,input().split())
P = list(map(int,input().split()))
s = pd.Series(P)
a = s.rolling(K).sum().max()

print(K + (a-K)*0.5)

Submission status: Runtime Error

Solution code:
import numpy as np
import copy

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

p1 = np.array(p)
p1 = (p1 + 1)/2
p2 = copy.copy(p1)

if k == 1:
  print(np.max(p1))
else:
  p3 = np.tile(p1,(k,1))
  for i in range(k):
    p3[i,] = np.roll(p2,i)

  sums = np.sum(p3, axis= 0)
  print(np.max(sums[k-1:]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

import numpy as np

n, k = na()
p = na()
d = [0] * (n + 1)
for i in range(n):
    a = (p[i] * (p[i] + 1) // 2) * (1 / p[i])
    d[i + 1] = d[i] + a

ans = 0.0
for i in range(n - k + 1):
    a = d[i + k] - d[i]
    ans = max(ans, a)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
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)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


ans=[]
for j in  range(1,N-K+1):
    temp=0
    temp+=(0.5*(sum(p[j:j+K])+K))
    ans.append(temp)
    

print(max(ans))

Submission status: Runtime Error

Solution code:
def cal_ans(x):
    ans = (x*(x+1)/2)/x
    return ans
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = list(map(cal_ans,p))

ans_temp = 0
ans_list = []
for i in range(n-k+1):
    if ans_temp < np.sum(p[i:i+k]):
            ans_temp = np.sum(p[i:i+k])
print(ans_temp)

Submission status: Runtime Error

Solution code:
n,k,*p = map(int, open(0).read().split())
l = []
for i in range (0,len(p)-k+1):
  s = sum(p[i:i+k]) 
  l.append(s)
max_idx=l.index(max_val)
exp = []
for i in range (max_idx,max_idx+k):
  ex=0
  for k in range(1,p[i]+1):
    px = k*(1/p[i])
    ex = ex + px
  exp.append(ex)
print(sum(exp))

Submission status: Runtime Error

Solution code:
import numpy as np
from scipy.signal import convolve

n, k = map(int, input().split())
P = np.array(input().split(), dtype=int)
template = np.ones(k)

a = convolve(P, template, mode="valid", method="fft")

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

Submission status: Runtime Error

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


for i in range(0, N-K+1):
  wa = sum(s[i:i+K])
  if wa>wa_max:
    max_numbers = list(s[i:i+K])
    wa_max = wa

wa_kitai = 0

for v in max_numbers:
  wa_kitai += sum(list(range(int(v)+1)))/int(v)
print(wa_kitai)

Submission status: Runtime Error

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

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
print(ans)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
c=[]
for i in range(len(p)-2):
  c.append(sum(p[i:i+3]))
  if max(c)==sum(p[i:i+3]):
    k=i

d=0
e=0
f=0
for l in range(1,p[k]+1):
  d=d+(l/p[k])
for l in range(1,p[k+1]+1):
  e=e+(l/p[k+1])
for l in range(1,p[k+2]+1):
  f=f+(l/p[k+2])
print(d+e+f)

Submission status: Runtime Error

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

tmp_max = 0
tmp_pair = []
for i in range(len(p)-K+1):
    #print(p[i:i+3])
    if sum(p[i:i+K]) > tmp_max:
        # 最大値更新
        tmp_max=sum(p[i:i+K])
        # 最大値のペアを変更
        tmp_pair=p[i:i+K]
        
#print("tmp_max", tmp_max)
#print("tmp_pair",tmp_pair)

def kitaichi(dice):
    import numpy as np
    dice = range(1,dice+1)#サイコロの事象
    ex = 0#期待値を演算するための変数
    p = 1/len(dice)#サイコロの確率

    tmp = np.array(dice)
    
    ex = tmp * p
    
    #print("EX = ",sum(ex))
    return(sum(ex))

print(kitaichi(tmp_max+K-1))

Submission status: Runtime Error

Solution code:
N, K = [int(num) for num in input().split(' ')]
As = [float((1.0+float(num))/2.0) for num in input().split(' ')]
 
max_ = -1.0
dp = []

for k in range(K):
	if k==0:
		dp.append(As)
	else:
		dp_k=[]
		for n in range(K-k+2):
			dp_k.append(dp[k-1][n]+As[n+k])
		dp.append(dp_k)
print(max(dp[-1]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
maxsize = 0
expectsum = 0
for i in range(N-K):
    if P[i]>P[i+K]:
        pass 
    else:
        sum_3 = sum(P[i+1:i+K+1])
        if sum_3 >= max_size:
            max_size = sum_3
            expect = 0
            for j in range(K):
                expect += (P[i+1+j]+1)/2
                if expect > expectsum:
                    expectsum = expect
print(expectsum)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))

# 1 - pi
ans = k
init = p[0]
for i in range(k, len(p)):
    if init < p[i]:
        init = p[i]
        ans = i

exp = 0
for i in range(ans - k + 1, ans + 1):
    exp += p[i]
print('{:.12f}'.format(exp))

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
cur = None
sum_cur = None
 
for i in range(N-K):
	cur = P[i:i+K]
	if sum_cur is None:
		sum_cur = sum(cur)
	else:
		sum_cur -= P[i-1]
		sum_cur += P[i+K-1]
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max_:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
while True:
    s = max_dice - ilist[i] + ilist[i+K]
    if s > max_dice:
        max_dice = s
        ind = i + 1
    if i == N-K-1:
        break
    else:
         i += 1
max_p = (sum(ilist[ind:ind+K])+K)/2
print(max_p)

Submission status: Runtime Error

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

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

S = 0
for i in p[i:i+k]:
  if i == 1:
    S += 1
  else:
    S += ((i-1)/2) + 1
print(S)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
maxsize = 0
expectsum = 0
for i in range(N-K):
    if P[i]>P[i+K]:
        pass 
    else:
        sum_3 = sum(P[i+1:i+K+1])
        if sum_3 >= max_size:
            max_size = sum_3
            expect = 0
            for j in range(K):
                expect += (P[i+1+j]+1)/2
                if expect > expectsum:
                    expectsum = expect
print(expect)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()

mx = sum(p[:K])
for i in range(0,N-K):
    a = mx - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

for i in range(N-2):
  if i == 0:
    ans = sum(E[i:i+K])
  else:
    ans = max(ans,sum(E[i:i+K]))
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import copy

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

p1 = np.array(p)
p1 = (p1 + 1)/2
p2 = copy.copy(p1)

if k == 1:
  print(np.max(p1))
else:
  p3 = np.tile(p1,(k,1))
  for i in range(k-1):
    p3[i,] = np.roll(p2,i+1)

  sums = np.sum(p3, axis= 0)
  print(np.max(sums[k-1:]))

Submission status: Runtime Error

Solution code:
import numpy as np

def getSlidingWindow(a, size, step=1):
    if not ((type(size) == type(0)) and (type(step) == type(0))):
        raise Exception("type(size) and type(step) must be int.")
    if step > size:
        raise Exception("step must not be larger than size.")
    if size > len(a):
        raise Exception("size must not be larger than array length.")
    a = np.asarray(a)
    h = ((len(a)-size)/step)+1
    indexer = np.arange(size)[None, :] + step*np.arange(int(h))[:, None]
    window = a[indexer]
    return window


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


a = [sum(getSlidingWindow(P, K)[i]) for i in range(N-K+1)]
print(K + (max(a)-K)*0.5)

Submission status: Runtime Error

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

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = round(tasu(p[i]) / p[i] , 6)

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

        if i == 0:
            count = sum(kitai[i:i+k]) % mod
        else:
            count -= kitai[i-1] % mod
            count += kitai[i + k] % mod
#        count = sum(kitai[i:i+k]) % mod
#       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: Runtime Error

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = P[:K]
ans = sum(memo)

for i in range(K, N):
    memo.pop(0)
    memo.append(P[i])
    if sum(memo) > ans:
        ans = memo

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

Submission status: Runtime Error

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

if len(p) == K:
    kitaiti = 0
    for i in range(len(p)):
        # 一個の数字
        sum = 0
        for j in range(p[i] + 1):
            sum += j
        kitaiti += sum / p[i]
    print(kitaiti)
else:
    max = 0
    max_index = 0
    # 期待値計算に使うリスト 最大のKつ並び
    l = []
    # 最大のKつ並びを見つける
    # iは始点(0スタート)
    # K + i は終点
    for i in range(len(p) - K + 1):
        tmp = sum(p[i:K + i])
        # もしmaxの次だったら、sumの計算が要らない
        # 共通部品以外を比較する
        if i != 0 and i == max_index + 1:
            if l[0] < p[K + i - 1]:
                max = tmp
                max_index = i
                l = p[i:K + i].copy()    
        elif tmp > max:
            max = tmp
            max_index = i
            l = p[i:K + i].copy()
        # もしmaxの次の次だったら、sumの計算が要らない
        # 共通部品以外を比較する
        if i != 0 and i == max_index + 2:
            if l[0] + l[1] < p[K + i - 1] + p[K + i - 2]:
                max = tmp
                max_index = i
                l = p[i:K + i].copy()    
        elif tmp > max:
            max = tmp
            max_index = i
            l = p[i:K + i].copy()
    
    # 期待値の計算
    kitaiti = 0
    for i in range(len(l)):
        # 一個の数字
        sum = 0
        for j in range(l[i] + 1):
            sum += j
        kitaiti += sum / l[i]
    print(kitaiti)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline
n, k = map(int, input().split())

p = list(map(lambda x: (x + 1) / 2, map(int, input().split())))

# 1 - pi
ans = k
init = p[0]
for i in range(k, len(p)):
    print(i)
    if init < p[i]:
        init = p[i]
        ans = i

exp = 0
for i in range(ans - k + 1, ans + 1):
    exp += p[i]
print('{:.12f}'.format(exp))

Submission status: Runtime Error

Solution code:
import numpy as np
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
x=np.array(w)
k=max(np.sum(x[i:i+q[1]]))
 
print((a+q[1])/2)

Submission status: Runtime Error

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

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = round(tasu(p[i]) / p[i] , 6)

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

        if i == 0:
            count = sum(kitai[i:i+k]) % mod
        else:
            count -= kitai[i-1]
            count += kitai[i + k]
#        count = sum(kitai[i:i+k]) % mod
#       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: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
cur = None
sum_cur = None
 
for i in range(N-K):
	cur = P[i:i+K]
	if sum_cur is None:
		sum_cur = sum(cur)
	else:
		sum_cur -= P[i-1]
		sum_cur += p[i+K-1]
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max_:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(N-K+1):
    m = sum(p[i:i+K])
    if m > max_l:
        max_l = m
        Max_l = p[i:i+K]


print((sum(L)+K)//2)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
while True:
    s = max_dice - ilist[i] + ilist[i+K]
    print(s)
    if s > max_dice:
        max_dice = s
        ind = i + 1
    if i == N-K-1:
        break
    else:
         i += 1
max_p = (sum(ilist[ind:ind+K])+K)/2
print(ind)
print(max_dice)
print(max_p)

Submission status: Runtime Error

Solution code:
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        s=i
for j in P[s+1:s+k+1]:
    ans+=np.cumsum(range(1,j+1))[-1]/j
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import copy

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

p1 = np.array(p)
p1 = (p1 + 1)/2
p2 = copy.copy(p1)
p3 = np.tile(p1,(k,1))

if k == 1:
  print(np.max(p1))
else:
  for i in range(k-1):
    p3[i,] = np.roll(p2,i+1)

  sums = np.sum(p3, axis= 0)
  print(np.max(sums[k-1:]))

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
P = [int(p) for p in input().split()]
if k ==1:
    Pmax = max(P)
else:
    amari = n % k
    tate = -(-n//k)+1
    zeroo = [0]*k
    zerozero = [0]*(2*k -amari)
    PPP =[zeroo[:i]+ P + zerozero[i:] for i in range(k)]
    PPP = np.array(PPP)
    PPP.reshape(k, tate, k)
    PPP[0].reshape(tate, k)
    Psum = np.sum(PPP, axis = 0)
    Pmax = max(Psum)
print((Pmax+k)/2)

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
cur = None
sum_cur = None
 
for i in range(N-K):
	cur = P[i:i+K]
	if sum_cur is None:
		sum_cur = sum(cur)
    else:
		sum_cur -= P[i-1]
		sum_cur += p[i+K-1]
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max_:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
max_size = 0
expectsum = 0
for i in range(N-K):
    if P[i]>=P[i+K]:
        pass 
    else:
        sum_3 = sum(P[i+1:i+K+1])
        if sum_3 >= max_size:
            max_size = sum_3
            expect = 0
            for j in range(K):
                expect += (P[i+1+j]+1)/2
                if expect > expectsum:
                    expectsum = expect
print(expect)

Submission status: Runtime Error

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

N,K=map(int,input().split())
p=list(map(int,input().split()))
t=0
k=sum(p[0:K])
s=[]

for i in range(N-K):
  k-=p[i]
  k+=p[i+K]
  s.append(k)
    
print((K+max(s))/2)

Submission status: Runtime Error

Solution code:
import numpy as np
def fact(n):
    if (n <= 1):
        return n
    return n + fact(n-1)

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

hoge = []
for i in range(N-K+1):
    sum = 0
    for k in range(K):
        div = fact(p[k + i])
        sum = sum + div / p[k + i]
    hoge.append(sum)

print(max(hoge))

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
maxsize = 0
expectsum = 0
for i in range(N-K):
    if P[i]>=P[i+K]:
        pass 
    else:
        sum_3 = sum(P[i+1:i+K+1])
        if sum_3 >= max_size:
            max_size = sum_3
            expect = 0
            for j in range(K):
                expect += (P[i+1+j]+1)/2
                if expect > expectsum:
                    expectsum = expect
print(expect)

Submission status: Runtime Error

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

p_max = max(p)

l_range = list(range(1001))
st = [sum(l_range[:i]) for i in range(1001)][1:]
#print(st)
table = [0] * (n + 1)
for i in range(1, len(table)):
    table[i] = table[i-1] + (st[p[i-1]] / p[i-1])
    #print(i, p[i-1], st[p[i-1]], table[i])
    
ans = table[k]
for i in range(k+1, len(table)):
    ans = max(ans, table[i] - table[i-k])

print(ans)

Submission status: Runtime Error

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

for i in range(n-k):
    if max(l[i:i+k-1]) < l[i+k]:
        m=l[i+1:i+k+1]
    else:
        m=l[i:i+k]

result=float(0)
for i in range(len(m)):
    t=m[i]
    if t%2==0:
        result += (1+t)*(t/2)/t
    else:
        result += ((1+t)*(t//2)+(t//2+1))/t
    
print(result)

Submission status: Runtime Error

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

def calc_exp(n):
    exp=1+(n-1)*0.5
    return exp

tmp=sum(p[:k])
mx=tmp
for i in range(1,n-k+1):
    # tmp=sum(p[i:i+k])
    tmp-=p[i-1]
    tmp+=p[i+k-1]
    if mx<tmp:
        ind=i
        mx=tmp
        
ans=0
for i in range(k):
    ans+=1+(p[ind+i]-1)*0.5
    
print(ans)

Submission status: Runtime Error

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

for i in range(N - K + 1):
  if 1 < i < N - K:
    if P[i + K] - P[i - 1] >= 0 and\
        P[i + K - 1] - P[i] <= 0:
      sum_pk = 0
      for j in range(K):
        sum_pk = sum_pk + P[i + j]
      max_sum = max([sum_pk,max_sum])
    else: continue
  elif i == 0:
    if P[i] - P[i + K] <= 0:
      sum_pk = 0
      for j in range(K):
        sum_pk = sum_pk + P[i + j]
      max_sum = max([sum_pk,max_sum])
    else: continue
  elif i == N - K:
    if P[i + K - 1] - P[i - 1] >= 0:    
      sum_pk = 0
      for j in range(K):
        sum_pk = sum_pk + P[i + j]
      max_sum = max([sum_pk,max_sum])
    else: continue
    
print(K / 2 + max_sum / 2)

Submission status: Runtime Error

Solution code:
N, K = input().split(" ")
N, K = int(N), int(K)
P = input().split(" ")
P = [int(p) for p in P]
 
max_ = None
sum_max = None
cur = None
sum_cur = None

for i in range(N-K):
  	cur = P[i:i+K]
	if sum_cur is None:
		sum_cur = sum(cur)
    else:
		sum_cur -= P[i-1]
        sum_cur += p[i+K-1]
	if sum_max is None or sum_cur > sum_max:
		max_ = cur
		sum_max = sum_cur
result = 0
for ele in max_:
	result += (ele+1)/2.
print(result)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
mycount=0
for i in range(N):
    if sum(p[i:i+K]) <= sum(p[i+1:i+K+1]):
        mycount=i
    else:
        pass

newcount=0
for j in range(K):
    goukei=(sum(range(0, p[mycount+j+1]))+p[mycount+j+1])/p[mycount+j+1]
    newcount=newcount+goukei
print(newcount)

Submission status: Runtime Error

Solution code:

input_first = input().split()
input_second= input().split()
N = int(input_first[0])
K = int(input_first[1])
in_list = [int(i) for i in input_second]

expect = []

for i in in_list:
    value = float(sigma(i)/i)
    expect.append(value)


# print(expect)
summ  = 0
for j in range(N-K+1):
    tmp = 0
    for p in range(K):
        # print("j",j,"p",p+j)
        tmp += expect[p+j] 


    if tmp > summ:
        summ = tmp
    # print("tmp",tmp)
print(summ)

Submission status: Runtime Error

Solution code:
s =0

print(n,a)

for f in range(n):
  
  for g in range(n):

    if g != f:
    	if a[f] == a[g]:
      		#print(a[f], a[g])
      		s = s+1
      
if s>0: print("NO")
else: print('YES')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
while True:
    s = max_dice - ilist[i] + ilist[i+K]
    i += 1
    if s > max_dice:
        max_dice = s
        ind = i
    if i == N-K-1:
        break
max_p = (sum(ilist[ind:ind+K])+K)/2
print(max_p)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
#mylist=[x]*
mycount=0
for i in range(N):
    if sum(p[i:i+K]) <= sum(p[i+1:i+K+1]):
#        print(i)
#        print(sum(p[i:i+K]))
        mycount=i
    else:
        pass

print(mycount)

newcount=0
for j in range(K):
#    print(p[mycount+j+1])
#    print(sum(range(0, p[mycount+j+1]))+p[mycount+j+1])
#    print(sum(range(0, p[mycount+j+1]))+mycount+j+1)
    goukei=(sum(range(0, p[mycount+j+1]))+p[mycount+j+1])/p[mycount+j+1]
    newcount=newcount+goukei
print(newcount)

Submission status: Runtime Error

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

final_answer=0
for i in range(N-K+1):
    ans=0
    for j in  range(i,i+K):
        ans+=(0.5*(p[j]+1))
        if ans>=final_ans:
            final_ans=ans

print(final_ans)

Submission status: Runtime Error

Solution code:
import statistics
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
print(sum([statistics.pstdev(x) for x in S]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

kitaiti = [0 for _ in range(n)]
ruisekiwa = [0 for _ in range(n)]
r = k - 1
max = 0
ans_list = []

for i in range(n):
    kitaiti[i] = (p[i]+1) / 2
    if i == 0:
        ruisekiwa[0] = kitaiti[0]
    else:
        ruisekiwa[i] = ruisekiwa[i-1] + kitaiti[i]
    if i == r:
        now = ruisekiwa[i]
    elif i > r:
        now = ruisekiwa[i] - ruisekiwa[i-r-1]
    if now > max:
        max = now
print(max)

Submission status: Runtime Error

Solution code:
import numpy as np
def fact(n):
    if (n <= 1):
        return n
    return n + fact(n-1)

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

hoge = []
for i in range(N-K+1):
    sum = 0
    for k in range(K):
        sum = sum + p[i + k]
    hoge.append(sum)

max_index = np.argmax(hoge)


sum = 0.0
for i in range(K):
    div = fact(p[max_index + i])
    sum = sum + div / p[max_index + i]
    
print(sum)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
while True:
    s = max_dice - ilist[i] + ilist[i+K]
    i += 1
    if s > max_dice:
        max_dice = s
        ind = i
    if i <= N-K-3:
        if ilist[i] >= ilist[i+K]:
            i += 2
        elif ilist[i] < ilist[i+K]:
            i += 1
    elif i <= N-K-2:
        i += 1
    elif i == N-K-1:
        break     
max_p = (sum(ilist[ind:ind+K])+K)/2
print(max_p)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = [0] * 10000

rmax = -1
pos = -1
for i in range(n-k+1):
    _t = sum(p[i: i+k])
    if pos < _t:
        pos = _t
        rmax = i

ans = 0
for i in range(rmax, rmax+k):
    if tmp[i] == 0:
        t = 0
        for j in range(1, p[i]+1):
            t += j
            #tmp[j] = t / j
        t = t / p[i]

        tmp[i] = t
        ans += t
#        print(t)
#    else:
#        ans += tmp[i]
#        print(tmp[i])

print(ans)

Submission status: Runtime Error

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

#累積和を前計算
sum_list = [0 for _ in range(300000)]
sum = 0

for i in range(len(p)):
    sum += p[i]
    sum_list[i] = sum

#答えを計算
mev = 0
idx = 0
for i in range(N-K+1):
    ev = sum_list[i+K]-sum_list[i]
    if ev > mev:
        idx = i
        mev = ev

mev = 0
for i in range(idx+1,idx+1+K):
    mev += (p[i] + 1.0) / 2.0

print(mev)

Submission status: Runtime Error

Solution code:
#At coder 2020/2/9 D
import numpy as np

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=[0] * (N-K+1)
p=np.array(p)
if N==K:
    kk=sum(p)
else:
    for ii in range(N-K+1):
        kk[ii]=np.sum(p[ii:K+ii])
kk=max(kk)
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

Submission status: Runtime Error

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
al = []
for i in range(k):
    pp = p[max_index+i]
    if pp = 200000:
        ans += 2000010000.0000002
    else:
        for j in range(pp):
            ans += (1/pp*(j+1))
            al.append(ans)
    
print(ans)

Submission status: Runtime Error

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

#累積和を前計算
sum_list = [0 for _ in range(2000)]
sum = 0

for i in range(len(p)):
    sum += p[i]
    sum_list[i] = sum

#答えを計算
mev = 0
idx = 0
for i in range(N-K+1):
    ev = sum_list[i+K]-sum_list[i]
    if ev > mev:
        idx = i
        mev = ev

mev = 0
for i in range(idx+1,idx+1+K):
    mev += (p[i] + 1.0) / 2.0

print(mev)

Submission status: Runtime Error

Solution code:
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
A=(N-K+1)
for i in range(A):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count.keys())
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)

Submission status: Runtime Error

Solution code:
def Sum(sum, a):
    if a == 1:
        return sum + 1
    else:
        return Sum(sum + a, a - 1)

N, K = map(int, input().split())
PList = list(map(int, input().split()))
KList = []

tmp = 0
Ktmp = 0
    
for i in range(0, N):
    KList.append(Sum(0, PList[i]) / PList[i])

for i in range(0, N - K + 1):
    for q in range(i, K + i):
        Ktmp += KList[q]
    
    if Ktmp > tmp:
        tmp = Ktmp
    Ktmp = 0

print(tmp)

Submission status: Runtime Error

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