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:
import numpy as np

N, K = map(int, input().split())
p = np.aray(list(map(int, input().split())))
ans = 0

for n in range(N-K+1):
	#tmp = sum(list(map(lambda x: (x+1)/2, p[n:n+K])))
	tmp = sum((p[n:n+K]+1)/2)
    if ans < tmp:
		ans = tmp

print(ans)

Submission status: Runtime Error

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

n,k=map(int,input().split())
p=list(map(int, input().split()))
sum_list=[]
syokiti=0
for i in range(k):
    syokiti+=exp(p[i])
for i in range(1,n-k+1):
    syokiti=syokiti-exp(p[i-1])+exp(p[i+k-1])
    sum_list.append(syokiti)

print(max(sum_list))

Submission status: Runtime Error

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

n,k=map(int,input().split())
p=list(map(int, input().split()))
sum_list=[]
syokiti=0
for i in range(k):
    syokiti+=exp(p[i])
for i in range(n-k):
    syokiti=syokiti-exp(p[i])+exp(p[i+k])
    sum_list.append(syokiti)

print(max(sum_list))

Submission status: Runtime Error

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

n,k=map(int,input().split())
p=list(map(int, input().split()))
sum_list=[]
syokiti=0
for i in range(k):
    syokiti+=exp(p[i])
for i in range(n-k-1):
    syokiti=syokiti-exp(p[i])+exp(p[i+k])
    sum_list.append(syokiti)

print(max(sum_list))

Submission status: Runtime Error

Solution code:
B,C = list(map(int,input().split()))
n_l = list(map(int,input().split()))
dic = {1:1,2:1.5,3:2,4:2.5,5:3,6:3.5}
A = []
total = 0
for i in range(B-C+1):
    A.append(sum(n_l[i:i+C]))
place = A.index(max(A))
for i in range(C):
    total += dic[n_l[place+i]]
print(total)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
    a = 0
    for j in range(k):
        a += ((1+p[i+j])*p[i+j])/2
    if ans <= a:
        ans = a

ans_list.sort(reverse=True)
print(ans)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=map(int,input().split())
maxvalue=0
for i in range(N-K):
  maxvalue=max(maxvalue,sum(A[K:N+K]))
print(maxvalue)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

expected_value = []
for i in range(len(p)):
    value = 0
    for j in range(1, p[i] + 1):
        value += j / p[i]
    expected_value.append(value)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K]
    cumsum.append(cumsum_temp)

print(max(cumsum))

Submission status: Runtime Error

Solution code:
# coding: utf-8
N, K = map(int, input().split())
p=list(map(int,input().split()))
p2=[0 for i in range(N)]
count=0

for i in range(N):
    count+=p[i]
    p2[i]=count

maxNum=p2[K-1]
maxIndex=0
for i in range(1,N-K+1):
    if p2[i+K-1]-p2[i-1]>=maxNum:
        maxNum=p2[i+K-1]-p2[i-1]
        maxIndex=i
        
count=0
deno=1
num=0
for i in range(K):
    deno*=p[maxIndex+i]

p3=[0 for i in range(200000)]
count=0
for i in range(200000):
    count+=i
    p3[i]=count

for i in range(K):
    num+=p3[p[maxIndex+i]]*(deno/p[maxIndex+i])
print(num/deno)

Submission status: Runtime Error

Solution code:
# coding: utf-8
N, K = map(int, input().split())
p=list(map(int,input().split()))
p2=[0 for i in range(N)]
count=0

for i in range(N):
    count+=p[i]
    p2[i]=count
maxNum=p2[K-1]
maxIndex=0
for i in range(1,N-K+1):
    if p2[i+K-1]-p2[i-1]>maxNum:
        maxNum=p2[i+K-1]-p2[i-1]
        maxIndex=i
        
count=0
deno=1
num=0
for i in range(K):
    deno*=p[maxIndex+i]
for i in range(K):
    for j in range(p[maxIndex+i]):
        num+=(j+1)*(deno/p[maxIndex+i])
print(num/deno)

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
A=[0]*N #期待値の累積和を入れる
A[0]=(p[0]+1)/2
for i in range(1,N):
  A[i]=A[i-1]+(p[i]+1)/2
#隣接するK個のさいころの期待値の和をすべて求める
B=[]
for j in range(N-K):
  s=A[j+K-1]-A[j]
  B.append(s)
print(max(B))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p,reverse=True)
s=0
for i in range(K):
  s+=((1+p[i])/2
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
points = [int(n) for n in input().rstrip().split()]

sum = sum(points[:use_num])
max_sum = sum
    
for i in range(dice_num-use_num):
    next = sum + points[i+use_num] - points[i]
    max_sum = max(next,max_sum)
    sum = next
    
max_sum_expectation = (use_num + max_sum)/2

print(max_sum_expectation)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = []
for i in range(N):
  P[i] = (P[i]+1)/2
hope = list(accumulate(P))
 
for j in range(N-K):
  ans.append(hope[j+K]-hope[j])
print(max(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

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

sum = 0
sumlist = []
for i in range(n):
    sum += a[i]
    sumlist.append(sum)

Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k-1]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array(lr(), np.float64)
P += 1; P /= 2
P = [0] + P
Pcum = P.cumsum()
expectation = Pcum[K:] - Pcum[:-K]
answer = expectation.max()
print(answer)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array(lr(), np.float32)
P += 1; P /= 2
P = [0] + P
Pcum = P.cumsum()
expectation = Pcum[K:] - Pcum[:-K]
answer = expectation.max()
print(answer)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array(lr(), np.float32)
P += 1; P /= 2
P = [0] + P
print(P)
Pcum = P.cumsum()
expectation = Pcum[K:] - Pcum[:-K]
answer = expectation.max()
print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np

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

S = []
ahi = 0.
ans = 0.
for i, n in enumerate(ps):
    ahi += (n + 1.) / 2.
    S.append(ahi)

    if i >= K:
        ans = max(ans, S[i] - S[i-K])
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

S = []
ans = -1
for n in ps:
    S.append((n + 1.) / 2.)

a = np.array([S[i:i+K] for i in range(N-K+1)])
print(np.max(np.sum(a, axis=0)))

Submission status: Runtime Error

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

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

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

Submission status: Runtime Error

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

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

if(n == k):
    max = rsum[n]
else:
    for i in range(n-k):
        if(max < rsum[i+k] - rsum[i]):
            max = rsum[i+k] - rsum[i]
print(max)

Submission status: Runtime Error

Solution code:
input_line=input().split(" ")
N,K=int(input_line[0]),int(input_line[1])
P=input().split(" ")
cumsum=[0]
tol=0
for i in range(N):
    P[i]=(int(P[i])+1)/2
    tol=tol+P[i]
    cumsum.append(tol)
    
k_sum=[]

for i in range(K):
  k_sum.append(cumsum[i+K]-cumsum[i])  

ans=max(k_sum)
print(ans)

Submission status: Runtime Error

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  p = input_list()
  kakus = [(1+p[0])/2]
  for i in range(1, n):
    kaku = (1+p[i])/2
    pre = kakus[i-1]
    kakus.append(kaku+pre)
  ans = []
  for i in range(len(p)-k):
    ans.append(kakus[i+k]-kakus[i])
  print(max(ans))
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Runtime Error

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  p = input_list()
  kakus = [1+p[0]/2]
  for i in range(1, n):
    kaku = (1+p[i])/2
    pre = kakus[i-1]
    kakus.append(kaku+pre)
  ans = []
  for i in range(len(p)-k):
    ans.append(kakus[i+k]-kakus[i])
  print(max(ans))
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Runtime Error

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

for i in range (len(p)):
    p[i]=int(p[i])

pre=[0 for i in range (n)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

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

print((ans+k)/2)

Submission status: Runtime Error

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

for i in range (len(p)):
    p[i]=int(p[i])

pre=[0 for i in range (n)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i+1]

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

print((ans+k)/2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range (len(p)):
    p[i]=int(p[i])

pre=[0 for i in range (n-k)]
q=0

for i in range(n-k):
    for j in range(i,i+k):
       pre[i]=pre[i]+p[j]
    
ans=max(pre)

print((ans+k)/2)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
num = list(map(int, input().split()))
import numpy
res = numpy.cumsum(num)
maxRange = 0
for i in range(n-k+1):
  r = res[i+k-1] - res[i]
  if maxRange < r:
    maxRange = max(r, maxRange)
    p, q = i, i+k-1
ans = 0
for j in range(p, q+1):
  ans += (num[j]-1)//2　
print(ans)

Submission status: Runtime Error

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

E_sum = []
for i in range(n-k+1):
    sum_k = 0
    for j in range(i, i+k):
        sum_k += E_p[j]
    E_sum.append(sum_k)

ans = max(E_sum)
print(f'{ans:.12f}')

Submission status: Runtime Error

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

E_sum = []
for i in range(n-k):
    sum_k = 0
    for j in range(i, i+k):
        sum_k += E_p[j]
    E_sum.append(sum_k)

ans = max(E_sum)
print(f'{ans:.12f}')

Submission status: Runtime Error

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

E_sum = []
for i in range(n-k):
    sum_k = 0
    for k in range(i, i+k):
        sum_k += E_p[k]
    E_sum.append(sum_k)

ans = max(E_sum)
print(f'{ans:.12f}')

Submission status: Runtime Error

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

E_sum = []
for i in range(n-2):
    E_sum.append(E_p[i]+E_p[i+1]+E_p[i+2])

ans = max(E_sum)
print(f'{ans:.12f}')

Submission status: Runtime Error

Solution code:
ajlfsajlfjfjalsjdfkljflakjfmldkajflsakdkcvnakjhefkugkeu

Submission status: Runtime Error

Solution code:
N, K = list(map(int,input().split()))
p = list(map(int,input().split()))
P = sorted(p,reverse = True)
Sum = [0 for _ in range(N-1)]
exp = [0 for _ in range(N-1)]
Exp = 0
for i in range(N-1):
  for j in range(P[i]+1):
    Sum[i] += j
  exp[i] = Sum[i]/P[i]
for i in range(0,K):
  Exp += exp[i] 
print(Exp)

Submission status: Runtime Error

Solution code:
def kaidan(n):
    if n >= 1:
        return n+kaidan(n- 1)
    else:
        return 0
    
    
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = []
tmp = [0]
num = 0
for i in range(n):
    i += num
    
    if sum(tmp) < sum(num_list[i:i+k]):
        tmp = num_list[i:i+k]
    else:
        candidate.append(tmp)
        num += 2
        
    if i == n-k:
        candidate.append(tmp)
        break
        
ans = 0
for i in candidate:
    tmp = 0
    for j in i:
        tmp += kaidan(j)/j
    if tmp > ans:
        ans = tmp
        
print(ans)

Submission status: Runtime Error

Solution code:
def kaidan(n):
    if n >= 1:
        return n+kaidan(n- 1)
    else:
        return 0
    
    
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = []
tmp = [0]
num = 0
for i in range(n):
    i += num
    
    if sum(tmp) < sum(num_list[i:i+k]):
        tmp = num_list[i:i+k]
    else:
        candidate.append(tmp)
        num += 2
        
    if i == n-k:
        candidate.append(tmp)
        break
        
ans = 0
for i in candidate:
    tmp = 0
    for j in i:
        tmp += kaidan(j)/j
    if tmp > ans:
        ans = tmp

Submission status: Runtime Error

Solution code:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
result = deque()
append = result.append
for el in p[k:]:
    d.popleft()
    d.append(el)
    append(sum(d))
print(max(result))

Submission status: Runtime Error

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
from collections import deque
l = []
for i in range(len(li)):
    l.append((1+ li[i])/2)
from itertools import accumulate
a = list(accumulate(l))
M = a[y-1]
for i range(len(a)-y):
    m = a[i+y] - a[i]
    if m > M:
        M = m
print(M)

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.custom()
x = Pcum[K:] - Pcum[0:-K]
print(x.max()/2)

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as numpy

data = np.fromstring(read(), np.int64, sep = ' ')

N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.custom()
x = Pcum[K:] - Pcum[0:-K]
print(x.max()/2)

Submission status: Runtime Error

Solution code:
import strutils, sequtils
var
  a, p = stdin.readline.split.map(parseFloat)
  n, k: int
(n, k) = a.map(toInt)

p = @[0.0] & p
for i in 1..n:
  p[i] *= (p[i]+1) / (2*p[i])
  p[i] += p[i-1]

var ans = 0.0
for i in 0..n-k: ans = max(ans, p[i+k]-p[i])
echo ans

Submission status: Runtime Error

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

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

def allsum(x):
  return x * (x+1) // 2

ans = 0
for j in range(K):
  ans += allsum(p[n+j]) / p[n+j]
print(ans)

Submission status: Runtime Error

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

r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = p1.cumsum()
p2 = np.array([(s1[i+K] - s1[i]) for i in range(N-K)])
max = np.amax(p2)
print((max+K) / 2)

Submission status: Runtime Error

Solution code:
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = np.array([np.sum(p1[0:i+1]) for i in range(N)])
p2 = np.array([(s1[i+K] - s1[i]) for i in range(N-K)])
max = np.amax(p2)
print((max+K) / 2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

template <class T>
struct BIT {
  std::vector<T> bit;
  BIT(int n) : bit(n+1, 0) {}
  void add(int x, const T &w) {
    for (int i = x; i < bit.size()-1; i |= (i+1)) {
      bit[i] += w;
    }
  }
  T sum(int r) {
    T ret = 0;
    for (int i = r-1; i >= 0; i = (i & (i+1)) - 1) {
      ret += bit[i];
    }
    return ret;
  }
  T sum(int l, int r) { return sum(r) - sum(l); }
};

int main() {
  int n, k; cin >> n >> k;
  BIT<double> tree(n);
  for (int i = 0; i < n; i++) {
    int p; cin >> p;
    tree.add(i, (1 + p) / 2.0);
  }
  double ans = 0.0;
  for (int i = 0; i + k <= n; i++) {
    ans = max(ans, tree.sum(i, i+k));
  }
  cout << ans << endl;
  return 0;
}

Submission status: Runtime Error

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

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

np=list(float, map(estimate),p)
sum=0

for i in range(1,n-k+2):
    short_p=np[i-1:i+k-1]
    if sum(short_p)>0:
        sum=sum(short_p)
print(sum)

Submission status: Runtime Error

Solution code:
straights=[]
nk =input().rstrip().split(" ")
n =int(nk[0])
k =int(nk[1])
numbers =input().rstrip().split(" ")
rank=sorted(numbers)
for i in range(k):
  answer=answer+rank[i]
trans=(answer+k)/2

Submission status: Runtime Error

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

ans=0
tmp=0
tmp2=sum(s[0:k])
for i in range(n-k):
    tmp2 -= s[i]
    tmp2 += s[k+i]
    if tmp < tmp2:
        tmp = tmp2
        kukan = [i+1,i+k+1]

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)

Submission status: Runtime Error

Solution code:
M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
q=0
for i in range(N-K+1):
    if i ==0:
        q=S[K-1]
    else:
        q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))

Submission status: Runtime Error

Solution code:
import math

M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
q=0
for i in range(N-K):
    if i ==0:
        q=S[K]
    else:
        q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))

Submission status: Runtime Error

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

p_e = [0] + [ (x + 1) * 0.5 for x in p]
p_p = [0]

for i in range(1, n+1):
    p_p.append(p_p[i-1] + p_e[i])

e_sum = [p_p[i] - p_p[i - k] for i in range(k+1, n+1)]
print(max(e_sum))

Submission status: Runtime Error

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

p_e = [ (x + 1) * 0.5 for x in p]
p_p = [p_e[0]]

for i in range(1, n):
    p_p.append(p_p[i-1] + p_e[i])

e_sum = [p_p[i] - p_p[i - k] for i in range(k, n)]
print(max(e_sum))

Submission status: Runtime Error

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


def expected(n):
    return (1+n)/2

p=list(map(expected,p))
for i in range(N-K+1):
    maxexp=max(p[i]+p[i+1]+p[i+2],maxexp)
print(maxexp)

Submission status: Runtime Error

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

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


B = []
init_ = sum(P[0:k])
max_ = 0
for i in range(0, n - k+1):
    if i != 0:
        init_ = init_ - P[i] + P[i+k-1]
    if max_ < init_:
        B = P[i:i+k]
        max_ = init_
B = sorted(B)
i = 0
t = 0
C = []
for j in range(B[-1]+1):
    t += j
    if j == B[i]:
        C.append(t)
        i += 1

ans = 0
for i in range(k):
    ans += C[i] / B[i]
print(ans)

Submission status: Runtime Error

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

p_mean = [(i+1)/2 for i in p]

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

for i in range(1, n):
    p_ruikei[i] = p_ruikei[i-1] + p_mean[i]

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

    if i==0:
        mean = p_ruikei[i+k-1]
    else:
        mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)

Submission status: Runtime Error

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

pi = [0 for _ in range(n)]
si = [0 for _ in range(n)]

pi = [int(s) for s in input().split()]
pi = [(1+s)/2 for s in pi]

si[0] = pi[0]
for i in range(1,n):
    si[i] = si[i-1] + pi[i]

#print(pi)
#print(si)
#print(si[2]-si[0])

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

print(float(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

# 期待値は(1+P)/2 https://rikeilabo.com/sum-formula-of-numerical-sequence
# 累積和を求めておく．隣接するK個の和はS_{j+K} - S_j
# 期待値の前計算→累積和の計算→隣接するK項の和の計算 (１乗オーダー)
E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  # i番目までのサイコロの期待値の累積和
for i in range(len(dices)):
    # S_list.append(sum(E_list[:i + 1]))  # アホ
    S_list.append(E_list[0] if i == 0 else S_list[i - 1] + E_list[i])

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))))

Submission status: Runtime Error

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

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

# 期待値は(1+P)/2 https://rikeilabo.com/sum-formula-of-numerical-sequence
# 累積和を求めておく．隣接するK個の和はS_{j+K} - S_j
# 期待値の前計算→累積和の計算→隣接するK項の和の計算 (１乗オーダー)
E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  # i番目までのサイコロの期待値の累積和
for i in range(len(dices)):
    S_list.append(sum(E_list[:i + 1]))

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

e=[0]*n

for i in range(n):
  e[i]=(1+p[i])/2
  if i!=0:
    e[i]+=e[i-1]

arr=[]

for i in range(k,n):
  s=i-k
  arr.append(e[i]-e[s])

print(max(arr))

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

for i in range(K):
    S += (P[i]+1)/2
ans = S
for i in range(N-K)
    S += (P[i+k]-P[i])/2
    ans = S if S>ans 

print(ans)

Submission status: Runtime Error

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

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    # print(d)

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        max_sum = max(max_sum, d[i + k] - d[i])
    # print(max_sum)

    # r_array = [sum(p[i:i + k]) for i in range(rangeN)]
    print((max_sum / 2) + (k * 0.5))

Submission status: Runtime Error

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

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
for i in range(n-k+1):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        initial = sum(p1[0:k])
        for i in range(n-k+1):
            cal = initial-p1[i]+p1[i+k]
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
    b.append(b[-1]+a[i])
max=0
for j in range(k,len(b)+1):
    if max<b[j]-b[j-k]:
        max=b[j]-b[j-k]
print((max+k)/2)

Submission status: Runtime Error

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
input_data = input().split()
data = [int(n) for n in input_data]
data_exp = []
for d in data:
    data_exp.append(1 + (d-1)/2)

ans = 0
for i in range(0, n-k+1, 1):
    exp_val = 0
    for j in range(k):
        exp_val += data_exp[i+k]
    ans = max(ans, exp_val)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(max(p[:k-1]))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

def judge(conf_list , info_list):
    conf_list = conf_list.split()
    dice_num = int(conf_list[0])
    adjacent = int(conf_list[1])
    
    info_list = info_list.split()
    
    sum_list = []
    for number in range(len(info_list) - adjacent - 1):
        current_result = 0
        for sum_num in range(adjacent):
            current_result = current_result + int(info_list[number + sum_num]) + 1
    
        sum_list.append(current_result)
    result = max(sum_list) / 2
    print(result)
            
        

def main():
    config = input()
    information = input()
    judge(config , information)



if __name__ == "__main__":
    main()