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

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
if N==1:
  print(max_e)
else:
for i in range(0,N-K-1):
    e=s[i+K]-s[i]
    #print(e)
    e=(K+e)/2
    #print(e)
    max_e = max(max_e, e)

  print(max_e)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
num = sum(p_list[0:K])
max = 0
index = 0
value = 0

for i in range(n - k):
    num = num + p_list[i + k] - p_list[i]
    if num > max:
        max = num
        index = i + 1

for i in range(k):
    value += (1 + p_list[index + i])/ 2

print(value)

Submission status: Runtime Error

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l=list(map(int,input().split()))
    l2 = [(1+i)/2 for i in l]
    kitai=sum(l2[0:k])
    tmp = kitai
    for idx in range(n)[:n - k + 1]:
        tmp -= l2[idx]
        tmp += l2[idx+k]
        if (kitai < tmp):
           kitai = tmp
    print(kitai)
main()

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
print(max(ans))

Submission status: Runtime Error

Solution code:

N,K = map(int,input().split())
P_List=list(map(int,input().split()))
#print(N,K)
#print(P_List)

def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    #print(p,result)
    return result

def Kitaichi2(p):
    return (p+1)*0.5

kitaichi_list=[]
ruisekiwa_list=[]
ruisekiwa=0
for a in range(N):
    kitaichi_list.append(Kitaichi2(P_List[a]))
    ruisekiwa += Kitaichi2(P_List[a])
    ruisekiwa_list.append(ruisekiwa)

#print(kitaichi_list)
#print(ruisekiwa_list)
pre_max=0
temp_max=0
max_num=0
for j in range(N-(K-1)):
    if j == 0:
        temp_max = ruisekiwa_list[j+K] - 0
    else:
        temp_max = ruisekiwa_list[j+K] - ruisekiwa_list[j-1]
    

    if pre_max < temp_max:
        pre_max = temp_max
    temp_max=0

print(pre_max)

Submission status: Runtime Error

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

max_numbers = []
max_num = 0

for i in range(N-K+1):
    if sum(array[i:i+K]) > max_num:
        max_num = sum(array[i:i+K])
        max_numbers = array[i:i+K]

exv = 0
ev_dict = {}
for n in max_numbers:
    if n in ev_dict:
        evn += ev_dict[n]
    else :
        ev_dict.setdefault(n, 0)
        ev = (1+n) / 2
        exv += ev
        ev_dict[n] = ev
    
print(exv)

Submission status: Runtime Error

Solution code:
import sys
import math

input = sys.stdin.readline
n = int(input())
k = int(input())
t = n
m = 0
while t:
    m += 1
    t //= 10

def comb(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 9 ** k * comb(m-1, k)
tk = k

def dfs(i, mt, kt):
    a = i // 10 ** mt
    b = n // 10 ** mt
    if kt < 0:
        return 0
    if mt < kt:
        return 0
    if a < b:
        if mt > 0:
            return 9 ** kt * comb(mt, kt)
        else:
            return 1
    elif a > b:
        return 0
    if i == n and kt == 0:
        return 1
    elif i > n:
        return 0
    ret = 0
    for j in range(10):
        f = 0
        if j != 0:
            f = 1
        ret += dfs(i+j*10**(mt-1), mt-1, kt-f)
    return ret

t_ans = 0
for i in range(1, n // (10 ** (m-1) )+1):
    ti = i * 10 ** (m-1)
    t_ans += dfs(ti, m-1, k-1)

print(int(ans+t_ans))

Submission status: Runtime Error

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

new_p = [(1+i)/2 for i in p]
box=[]
sec_box=[]
s=0
for i in range(n):
    s = sum(new_p[:i])
    box.append(s)
    if i>k:
        sec_box.append(box[i]-box[i-k])
print(max(sec_box))

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
s = [0] * 200000
for i in range(N):
    s[i+1] = s[i] + A[i]

max_s = 0
for i in range(N):
    if max_s < s[i+K] - s[i]:
        max_s = s[i+K] - s[i]


print((max_s+K) / 2)

Submission status: Runtime Error

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

s=[(p[n]+1)/2 for n in range(N)]
S=[0 for _ in range(N)]

S[0]=s[0]
for n in range(N-1):
    S[n+1]=s[n+1]+S[n]

def sjk(j):
    return S[j+K]-S[j]
delta = [sjk(i) for i in range(N-K)]

print(max(delta))

Submission status: Runtime Error

Solution code:
import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
num = 0
maxnum = 0
for i in range(n-k+1):
    num = 0.5*(sum(p[i:i+k])+k)
    if num > maxnum:
        maxnum = num
print("{:.6f}".format(maxnum)

Submission status: Runtime Error

Solution code:
s = [0] * 200000
for i in range(N):
    s[i+1] = s[i] + A[i]

max_s = 0
for i in range(N):
    if max_s < s[i+K] - s[i]:
        max_s = s[i+K] - s[i]


print((max_s+K) / 2)

Submission status: Runtime Error

Solution code:
def a(b):
    c = 0
    if b == 1:
        return 1
    else:
        c = b + a(b-1)
        return c


y = input()
l = y.split()
n = int(l[0])
k = int(l[1])
p = input()
ll = p.split()
for i in range(0,n):
    ll[i] = int(ll[i])
ll = sorted(ll,reverse =True)
print(ll)
count = 0.00000000000000000
for i in range(0,k):
    z = a(ll[i])/ll[i]
    print(z)
    count = count + z
print(count)

Submission status: Runtime Error

Solution code:
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))

print(p)
E = []
tmp = 0
for el in p:
    tmp += el
    E.append(tmp)

print(E)
past = -20000
for el in range(len(E)):
    if el - K < 0:
        continue
    e = E[el] - E[el - K]
    if past < e:
        past = e
print(e)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
s = [0] * 200000
for i in range(N):
    s[i+1] = s[i] +A[i]

max_s = 0
for i in range(K):
    if max_s < s[i+K] - s[i]:
        max_s = s[i+K] - s[i]


print((max_s+K) / 2)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
d = list(map(int, input().split()))
e = [0]*n

for i in d:
    s = (1+i)*i/2
    e[i] = s / i

max1 = 0
idx = 0
tmp = 0
for j in range(n):
    if len(e[j:j+k]) < k:
        break
    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        idx = j
        max1 = tmp
print(max1)

Submission status: Runtime Error

Solution code:
import numpy as np

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

pcm=(p+1).cumsum()

print((pcm[K:]-pcm[0:-K]).max() /2)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = []
s = [0] * 200000
for i in range(K):
  a_k = int(input())
  s[i+1] = s[i] + a_k

max_s = 0
for i in range(K)
  if max_s < s[i+K] - s[i]:
    max_s = s[i+K] - s[i]
print(max_s)

Submission status: Runtime Error

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

p = [(N+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

max_e=0
for i in range(N-K+1):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(n-k+1):
    if i==0:
        t=sum(p[0:k])
    else:
        t=t-p[i-1]+p[i+k-1]
    ans=max(ans,ts)

print((ans+k)/2)

Submission status: Runtime Error

Solution code:
# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import collections

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

ma = sum(p[:K])
idx = 0

kukan = [sum(p[i:i+K]) for i in range(N-K)]
idx = kukan.index(max(kukan))

ans = 0
for i in range(K):
  ans += (0.5 * (p[idx+i]-1) + 1)

print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out_ = 0
p = P[0:K]
base = sum(p)
for i in range(N-K):
  out_ += P[i+K]-P[i]
  if i == 0:
    ans = out_
  else:
    if out_ > ans:
      ans = out_
    else:
      continue
answer = (base+ans+K)/2
print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

maxList = []
maxList_sum = 0
kitaichi = 0
for index in range(len(p)):
  list_p = p[index:index+K]
  if sum(list_p) > maxList_sum:
    maxList = list_p
    maxList_sum = sum(maxList)

for item in range(len(maxList)):
  # number = maxList[item]
  # s = sum(list(range(number+1)))
  # kitaichi += s / number
  kitaichi += (1 + number)/2

print(kitaichi)

Submission status: Runtime Error

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

box = [0]*(n-k+3)
su = sum(P[:k])
pu = sum(P[n-k+1:n+1])
box[0] = su
box[1] = pu

for i in range((n-k+2)//2):
    j = i+1
    box[2*j]  = su - P[i] + P[k+i]
    box[2*j+1]  = pu - P[n-j]+P[n-k-j]
print((max(box)+k)/2)

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+=(1+j)/2
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n, k = map(int, input().split())
p = np.array(list(map(int, input().split())))
p += 1
sum_e = np.cumsum(p)
ans = 0
for i in range(n-k+1):
    ans = max(ans, sum_e[i+k] - sum_e[i])
print(ans)

Submission status: Runtime Error

Solution code:
a=input().split()
N=int(a[0])
K=int(a[1])
zantei=0
P=list(map(float,input().split()))

P_ex=list(map(lambda x: (x+1)/2,P))


for i in range(0,K):
    
    zantei+=P_ex[i]
zanans=0
buffer=P_ex[0]
beforeans=zantei
for i in range(1,N-K+1):
    if(beforeans-buffer+P_ex[K+i-1]>zantei):
        zantei=breforeans+P_ex[K+i-1]-buffer
    buffer=P_ex[i]
    beforeans+=P_ex[K+i-1]-buffer

print(zantei)

Submission status: Runtime Error

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

print(max(r))

Submission status: Runtime Error

Solution code:
def ex_value(dice):
  n = 0
  for i in range(1,dice+1):
    n += i*1/dice
  return(n)
def main():
  n,k = map(int, input().split())
  list_p = list(map(ex_value, int(input().split())))
  print(max([sum(list_p[i:i+k]) for i in range(n-k+1)]))
     
if __name__ == '__main__':
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def ex_value(dice):
  n = 0
  for i in range(1,dice+1):
    n += i*1/dice
  return(n)
def main():
  n,k = map(int, input().split())
  list_p = list(map(ex_value, input().split()))
  list_ex_val = list(map(ex_value, list_p))
  print(max([sum(list_ex_val[i:i+k]) for i in range(n-k+1)]))
     
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextFloat64() float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func expectedValue(x float64) float64 {
	s := (x + 1) * (x / 2)
	return s / x
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	evs := make([]float64, n)
	for i := 0; i < n; i++ {
		p := nextFloat64()
		evs[i] = expectedValue(p)
	}

	// initialize
	var ev float64
	for i := 0; i < k; i++ {
		ev += evs[i]
	}

	maxEv := ev
	left := 0
	for i := k; i < n; i++ {
		ev = ev - evs[left] + evs[i]
		left++
		if ev > maxEv {
			maxEv = ev
		}
	}
	fmt.Printf("%0.7f\n", maxEv)
}

Submission status: Runtime Error

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, cp = 0, []
for i in range(N-K+1):
    t = sum(ps[i:i+K])
    if ans >= t:
        continue
    cp = ps[i:i+K]
    ans = t
    # ans = max(ans, sum(ps[i:i+K]))

ans, cp = 0, []
for i in range(((N-K)>>1)+1):
    t1 = sum(ps[i:i+K])
    t2 = sum(ps[-K:-1])
    if ans >= t1 and ans >= t2:
        continue
    if ans < t1:
        cp = ps[i:i+K]
        ans = t1
    if ans < t2:
        cp = ps[-K:-1]
        ans = t
    # ans = max(ans, sum(ps[i:i+K]))



cnt = 0
for i in range(K):
    n = cp[i]
    cnt += ((n*(1+n))>>1)/n

print(cnt)

# ans, cnt, buff = 0, 0, Queue()
# for p in map(int, input().split()):
#     buff.put(p)
#     if buff.qsize() == K:
#         kitaiti = 0
#         while not q.empty():
#             kitaiti = (buff[0]+buff[-1])>>1
#         if ans < kitaiti:
#             ans = kitaiti
#         buff = buff[1:K]
#     cnt += 1
# 
# # 出力
# print(ans)

Submission status: Runtime Error

Solution code:

n, k = [int(i) for i in input().split()]
num = [int(i) for i in input().split()]

renum =list(reversed(num))
renum2 = renum[:k]

for i in renum2:
    i = i + (i/6)
print(i**i)

Submission status: Runtime Error

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

for i in range(N):
  for j in range(j+3):
    sum = P[i]/6
    if sum >= val:
      val = sum
  
print(val)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out_ = 0
p = P[0:K]
base = sum(p)
for i in range(N-K):
  out_ += P[i+K]-P[i]
  if i == 0:
    ans = out_
  else:
    if out > ans:
      ans = out_
    else:
      continue
answer = (base+ans+K)/2
print(answer)

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()
a = sum(p[:K])
mx = a

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

print(float(mx))

Submission status: Runtime Error

Solution code:
import numpy as np
N, K = map(int, input().split())
ps = list(map(int, input().split()))
Es = np.array([sum(range(1, ps[i]+1))/ps[i] for i in range(N)], dtype=np.float64)
maxs = []
for i in range(N):
  if i<K:
    continue
  else:
    maxs.append(sum(Es[i-K:i]))
print(max(maxs))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
f = lambda x: int(x)+1
np_P = np.array(list(map(f, input().split())))
v = K*[1/2]
print(np.amax(np.fftconvolve(np_P,v)))

Submission status: Runtime Error

Solution code:
a,b = input().split()
arr = input().split()
b = int(b)
c = []
sum = 0
k = 0
print(arr)
for i in range(0 , len(arr) - b):
    k = 0
    for j in range(0 , b):
        k = int(arr[i+j]) + k
    c.append(k)
sum = (max(c) + b) / 2
print("{:.12f}".format(sum))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))

a=a[index:index+k]
total=0
for i in a:
  total+=sum(range(i+1))/i
print(total)

Submission status: Runtime Error

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

num_li = [0]*n
ans = 0
num = 0

for i in range(n):
    num_li[i] = ((p[i]*(p[i]+1))/2)/Decimal(p[i])

num = sum(num_li[:k])

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num,ans)

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

Submission status: Runtime Error

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

bigNumber = 0

for i in range(x-y+1):
    if sum(p[i:i+y]) > bigNumber:
        bigNumber = number

print((bigNumber + y) / 2)

Submission status: Runtime Error

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

for i in range(N):
  for j in range(j+3):
    sum = P[i]/6
    if sum >= val:
      val = sum
  
print(val)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out = 0
p = P[0:K]
base_ = sum(p)
for i in range(N-K):
  out += P[i+K]-P[i]
  if i == 0:
    ans = out
  else:
    if out > ans:
      ans = out
    else:
      continue
answer = (base_+ans+K)/2
print(answer)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = [i for i in map(int, input().split())]
items = []
for i in xrange(n):
  items += sum(l[i:i+k]),
print((max(items)+k)/2)

Submission status: Runtime Error

Solution code:
import numpy as np

N, K = map(int, input().split())
tmp_p = list(map(int, input().split()))
#N = 4
#K = 1
#tmp_p = (6, 6, 6, 6)

MAX_P = 1000

p = np.array(tmp_p, dtype=np.int64)
total_value = np.zeros(MAX_P, dtype=np.int64)
expect_value = np.zeros(N)

total_value[0] = 1
for i in range(1, MAX_P):
    total_value[i] = total_value[i-1] + i + 1

for i in range(0, N):
    expect_value[i] = total_value[p[i]-1] / p[i]

max_value = 0.0
for i in range(N-K):
    tmp_value = sum(expect_value[i:i+K])
    if max_value < tmp_value:
        max_value = tmp_value

print(tmp_value)

Submission status: Runtime Error

Solution code:
a,b = input().split()
arr = input().split()
b = int(b)
c = []
sum = 0
k = 0
print(arr)
for i in range(0 , len(arr) - b):
    k = 0
    for j in range(0 , b):
        k = int(arr[i+j]) + k
    c.append(k)
print(c)
sum = (max(c) + b) / 2
print("{:.12f}".format(sum))

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]=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:
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out = 0
p = P[0:K]
base = sum(p)
for i in range(N-K):
  out += P[i+K]-P[i]
  if i == 0:
    ans = out
  else:
    if out > ans:
      ans = out
    else:
      continue
answer = (base+ans+K)/2
print(answer)

Submission status: Runtime Error

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

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]) < 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:
import numpy as np
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

p = np.array(p)
max_sum = 0
ind = 0
for i in range(n-k+1):
    tmp_sum = np.sum(p[i:i+k])
    if(max_sum < tmp_sum):
        max_sum = tmp_sum
        ind = i

nums = p[ind: ind+k]

r = sum(map(lambda num: num / 2 + 0.5, nums)

print(r)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long N;
    long K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> p[i];
    }
    long ans = 0;
    for (long i = 1; i < N - K + 1; ++i)
    {
        long tmp;
        for (int j = 0; j < K; j++)
        {
            tmp += p[i + j];
        }
        if (tmp > ans)
        {
            ans = tmp;
        }
    }
    cout << (ans + K) / 2 << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = list(itertools.accumulate(A))
    
    if A[0] == 1 and len(A) == 1:
        return 1
    
    ans = 0
    for i in range(M, N):
        ans = max(ans, l[i] - l[i-M])
    
    ans = (ans+M) / 2
    
    return ans

print(solve())

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out = 0
p = P[0:K]
base = sum(p)
for i in range(N-K):
  out += P[i+K]-P[i]
  print(out)
  if i == 0:
    ans = out
  else:
    if out > ans:
      ans = out
    else:
      continue
answer = (base+ans+K)/2
print(base, ans)
print(answer)

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
p1 = p1 / 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:
def calcExValue(N):
    ev = []
    for i in range(1, N +1):
        ev.append(i * (1/N))
    return(sum(ev))

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

max_numbers = []
max_num = 0

for i in range(N-K+1):
    if sum(array[i:i+K]) > max_num:
        max_num = sum(array[i:i+K])
        max_numbers = array[i:i+K]

exv = 0
ev_dict = {}
for n in max_numbers:
    if n in ev_dict:
        evn += ev_dict[n]
    else :
        ev_dict.setdefault(n, 0)
        ev = calcExValue(n)
        exv += ev
        ev_dict[n] = ev
    
print(exv)

Submission status: Runtime Error

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

calEnd = N - 2
calCount = 0
calRes = 0
calIndex = 0
calCor = 0
calList = []
Counter = 0

for i in range(N - 2):
    calTemp = p[i] + p[i + 1] + p[i + 2]
    if calRes <= calTemp:
       calRes = calTemp
       calIndex = i
    
    calCount += 1

for o in range(K):
    cal = list(range(1, p[calIndex + Counter] + 1))
    Counter += 1
    calList.append(sum(cal) * (1 / len(cal)))

calCor = sum(calList)
print(calCor)

Submission status: Runtime Error

Solution code:
from collections import deque
n,k=map(int, input().split())
p=list(map(int, input().split()))
queue=deque()
prod=1
ans=0
for i in range(k):
    queue.append(p[i])
    prod*=p[i]
ans=sum(queue)
for i in range(k-1,n-1):
    buf=sum(queue)
    if buf>=ans: #隣接するkコのサイコロの最大値を記録
        ans=buf
        x=prod
    queue.popleft()
    queue.append(p[i+1])
    prod*=p[i+1]/p[i]
l=list(range(3,ans+1))
y=(sum(l))/x
print(y)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, k = MAP()
    p = LIST()
    p_ = list(accumulate(p))
    #print(p_)
    ans = 0
    tmp = 0

    for i in range(n-k):
        #print(i,p_[i+k]-p_[i])
        if tmp <= p_[i+k]-p_[i]:
            l = p[i+1:i+k+1]
            tmp = p_[i+k]-p_[i]

    #print('l:',l)
    k = list(accumulate(range(max(l)+1)))

    for x in l:
        ans += k[x]/x
        
    print(ans)

if __name__=='__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
k = input()
ma = 0.0
pt = 0
result = 0.0
dice = []

def fnc(num):
    if num == 1:
        return 1
    else:
        return num + fnc(num - 1)

for i in range(n):
    dice.append(float(input()))

for i in range(n-(k-1)):
    sum = 0.0
    for j in range(k):
        sum += dice[i+j]
    if sum > ma:
        ma = sum
        pt = i

for i in range(k):
    result += fnc(dice[pt+i]) / dice[pt+i]

print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit
@jit
def search(N, K, ps, ps_means, maxval):
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            a = ps[i-K+1:i+1]
            b = 1 / a  #[np.delete(a, i).prod() for i in range(K)]
            c = ps_means[i-K+1:i+1] * b
            sumval = np.sum(c)  #/ a.prod()
            if sumval > maxval:
                maxval = sumval
    return maxval

def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")

    ps_means = np.zeros(N)
    maxval = 0
    ans = search(N, K, ps, ps_means, maxval)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,k,*p=map(int,open(0).read().split())
p.sort()
p.reverse()
l=p[:k]
_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 = input()
k = input()
ma = 0.0
pt = 0
result = 0.0
dice = []

def fnc(num):
    if num == 1:
        return 1
    else:
        return num + fnc(num - 1)

for i in range(n)
    dice.append(float(input()))

for i in range(n-(k-1)):
    sum = 0.0
    for j in range(k):
        sum += dice[i+j]
    if sum > ma:
        ma = sum
        pt = i

for i in range(k):
    result += fnc(dice[pt+i]) / dice[pt+i]

print(result)

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 =　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
    e += sum(range(1, i+1)) / i
    # print(tmp)
    # e += tmp
print(e)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split(' '))
p = list(map(int, input().split(' ')))
# p_kitaichi = [(1 + v) / 2 for v in p]

l_kitaichi = [sum([ (1 + p[i+j]) / 2 for j in range(K)]) for i in range(N - K)]

print(max(l_kitaichi))