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: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
#さいころの出目の和を集計
for i in range(n):
    p[i]+=1

sdict={}
sdict[0]=p[0]

for i in range(n-1):
	sdict[i+1]=sdict[i]+p[i+1]
j=0
ans=0
while (j+k <n):
	dif=sdict[j+k]-sdict[j]
	ans=max(dif,ans)
	j+=1
print(ans/2)

Submission status: Wrong Answer

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

max = 0
for i in range(N - K):
    tmp = sum(pi[i : i + K])
    if tmp > max:
        max = tmp

if N == K:
    max = sum(pi)

out = (max + K) / 2

print(out)

Submission status: Wrong Answer

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

max = 0
maxi = 0
for i in range(N - K):
    tmp = sum(pi[i : i + K])
    if tmp > max:
        max = tmp
        maxi = i

out = 0
for j in range(K):
    exp = (pi[j + maxi] + 1) / 2
    out = out + exp

print(out)

Submission status: Wrong Answer

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

max = 0
maxi = 0
for i in range(N - K):
    tmp = sum(pi[i : i + K - 1])
    if tmp > max:
        max = tmp
        maxi = i

out = 0
for j in range(K):
    exp = (pi[j + maxi] + 1) / 2
    out = out + exp

print(out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_ = 0
pre = 0
for j in range(K):
    pre += l[j]
max_ = pre

if K>1 and N>K:
  for i in range(N-K):
    temp = pre
    temp += l[i+K]
    temp -= l[i]
    if temp > max_:
      max_ = temp
    pre = temp


print((max_+K)/2)

Submission status: Wrong Answer

Solution code:
N, K = (int(i) for i in input().split())
p = [int(i) for i in input().split()]
p_ex = [(i+1)/2 for i in p]
sum_list = [sum(p_ex[0:K]),sum(p_ex[N-K:N])]
tmp_num = sum_list[0]
if N == K:
  print(sum(p_ex))
else:
  for i in range(1,N-K):
    #print("i:"+str(i))
    tmp_num = tmp_num - p_ex[i-1] + p_ex[i+K]
    #print("  tmp_num = tmp_num - "+str(p_ex[i-1])+" + "+str(p_ex[i+K]))
    sum_list.append(tmp_num)
  print(max(sum_list))

Submission status: Wrong Answer

Solution code:
N, K = (int(i) for i in input().split())
p = [int(i) for i in input().split()]
p_ex = [(i+1)/2 for i in p]
sum_list = [sum(p_ex[0:K]),sum(p_ex[N-K:N])]
tmp_num = sum_list[0]
if N == K:
  print(sum(p_ex))
else:
  for i in range(1,N-K):
    print("i:"+str(i))
    tmp_num = tmp_num - p_ex[i-1] + p_ex[i+K]
    print("  tmp_num = tmp_num - "+str(p_ex[i-1])+" + "+str(p_ex[i+K]))
    sum_list.append(tmp_num)
  print(max(sum_list))

Submission status: Wrong Answer

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

max = 0
pre = 0
for j in range(K):
    pre += l[j]
max = pre

if K>1 and N>K:
  for i in range(N-K):
    temp = pre
    temp += l[i+K]
    temp -= l[i]
    if temp > max:
      max = temp
    pre = temp


print((max+K)/2)

Submission status: Wrong Answer

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

max = 0
pre = 0
for j in range(K):
    pre += l[j]
max = pre

if K>1:
  for i in range(N-K):
    temp = pre
    temp += l[i+K]
    temp -= l[i]
    if temp > max:
      max = temp
    pre = temp


print((max+K)/2)

Submission status: Wrong Answer

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

max = 0
pre = 0
for j in range(K):
    pre += l[j]

for i in range(N-K):
  temp = pre
  temp += l[i+K]
  temp -= l[i]
  if temp > max:
    max = temp
  pre = temp


print((max+K)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
ps = [0]*n
ps = list(map(lambda x: (int(x)+1) / 2,input().split()))
print(ps)
ans = 0
for i in range(k):
    ans += ps[i]
tmp = ans
for i in range(k,n):
        tmp = tmp - ps[i-k] + ps[i]
        if ans < tmp:
            ans = tmp
    
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
a.reverse()
s=0
for pi in a[:K]:
    ss=list(range(1,pi))
    ss=list(map(lambda x:x/pi,ss))
    s+=sum(ss)
print(s)

Submission status: Wrong Answer

Solution code:
N,K=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
a.reverse()
s=0
for pi in a[:K]:
    s+=sum(range(1,pi+1))/pi
print(s)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=[int(x) for x in input().split()]
sum=[]
exp=0
#さいころの出目の和を集計
for i in range(0,n):
    p[i]+=1

#区間毎の和を集計
for i in range(0, k):
    if i+k > n:
        break
    #exp+=p[i]
    for j in range(0,k):
       exp+=p[i+j]
    sum.append(exp)
    exp=0
print(max(sum)/2)

Submission status: Wrong Answer

Solution code:
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S = 0

for i in range(NK[0] - NK[1]):
    if S < sum(P[i:i+NK[1]]):
        S = sum(P[i:i+NK[1]])

print((S + NK[1]) / 2)

Submission status: Wrong Answer

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

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

s = [0] * N
for i in range(N-K):
    s[i] = p[i+K] - p[i]

print(max(s))

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 3
1 2 2 4 5
'''

def solve(l,k):
	n = len(l)
	subs = []
	for i in range(n-k+1):
		subs.append(l[i:i+k])
	maxx = -1
	sub = []
	for i in subs:
		summ = sum(i)
		if(summ > maxx):
			maxx = summ
			sub = i
	ans = 0
	for i in sub:
		curr = i*(i+1)/2
		ans += curr/i
	print(subs)
	return ans
	

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print("%.10f"%ans)

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5 3
1 2 2 4 5
'''

def solve(l,k):
	n = len(l)
	subs = []
	for i in range(n-k+1):
		subs.append(l[i:i+k])
	maxx = -1
	sub = []
	for i in subs:
		summ = sum(i)
		if(summ > maxx):
			maxx = summ
			sub = i
	ans = 0
	for i in sub:
		curr = i*(i+1)//2
		ans += curr/i
	print(subs)
	return ans
	

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print("%.10f"%ans)

Submission status: Wrong Answer

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

dicesum = 0
maxsum = 0
for i in range(n):
	if i < k:
		dicesum += p[i]
	else:
		dicesum += p[i]
		dicesum -= p[i-k]
		maxsum = max(maxsum, dicesum)

ans = (maxsum + k) / 2
print(ans)

Submission status: Wrong Answer

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

s = sum(p[0:k])

ans = 0


for i in range(n - k) :
    s += p[i + k]
    s -= p[i]
    if s > ans :
        ans = s

print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
for i in range(a):
    ar[i] += 1
    ar[i] /= 2
ans = 0
m = sum(ar[0:b])
j = 0
for i in range(b,a):
    m -= ar[j]
    m += ar[i]
    if ans < m:
        ans = m
    j += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

Q = list(accumulate(((v + 1) / 2) for v in P))

MAX = 0.0

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

print(MAX)

Submission status: Wrong Answer

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

start = 0
max = 0
for i in p[:len(p)-k+1]:
    res = 0.0
    for j in p[start:start+k]:
        res += 1 + j
    if max < res:
        max = res
    start += 1

print(res/2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
p.sort()
y = 0


def f(n):
    x = 0
    for i in range(n + 1):
        x += i
    return x / n


for j in range(n - k + 1):
    z = 0
    for i in range(k):
        z += p[-i - 1]
    if z > y:
        y = z
        a = 0
        for l in range(k):
            a += f(p[-l - 1])
    p.pop()

print(a)

Submission status: Wrong Answer

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

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

def calc_e(p):
    temp = 0.5 + 0.5 * p
    return temp

temp = sum(P[0:K])
temp_max = 0


for i in range(1,N - K + 1):
    temp = temp - P[i - 1] + P[i + K - 1]
    temp_max = max(temp,temp_max)


temp = 0
temp = calc_e(temp_max // K) * (K - 1) + calc_e(temp_max // K + temp_max % K)
print(temp)

Submission status: Wrong Answer

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

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

def calc_e(p):
    temp = 0.5 + 0.5 * p
    return temp

temp = sum(P[0:K])
temp_max = temp


for i in range(N - K - 1):
    temp = temp - P[i] + P[i + K + 1]
    temp_max = max(temp,temp_max)



temp = 0
temp = calc_e(temp_max // K) * (K - 1) + calc_e(temp_max // K + temp_max % K)
print(temp)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
p.sort()
y = 0


def f(n):
    x = 0
    for i in range(n + 1):
        x += i
    return x / n


for j in range(n - k + 1):
    z = 0
    for i in range(k):
        z += f(p[-i - 1])
    if z > y:
        y = z
    p.pop()

print(y)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(int(x) for x in input().split())
p.sort()
y = 0


def f(n):
    x = 0
    for i in range(n + 1):
        x += i
    return x / n


for i in range(k):
    y += f(p[-i - 1])

print(y)

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N[0]-N[1]-1):
    if (A[i+N[1]] - A[i] > 0) and (A[i+N[1]+1]-A[i+1]<=0):
        P = P + (i,)
P = P + (N[0]-N[1],)
print(P)

L = [0]*(len(P))

for i in range(len(P)):
    for j in range(N[1]):
        for k in range(A[P[i]+j]):
            L[i] += (k+1)/A[P[i]+j]
print(L)
print(max(L))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sum_=0
for i in range(k):
  sum_+=li[i]
max_=sum_
  
for i in range(k+1,len(li)):
  sum_-=li[i-k-1]
  sum_+=li[i]
  if max_<sum_:
    max_=sum_
max_+=k
max_/=2
print(max_)

Submission status: Wrong Answer

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n ,k = i2()
p = intl()
def sx(n):
    return (n+1)/2

m = 0
pnt = 0
s = 0
for i in range(0,n-k+1):
    if i == 0:
        s = sum(p[i:i+k-1])
    else:
        s = s - p[i] + p[i+k-1]
    if s > m:
        m = s
        pnt = i
cnt = 0.
for j in range(pnt,pnt+k):
    cnt += sx(p[j])
print(cnt)

Submission status: Wrong Answer

Solution code:
# 0 
# max_val
def expect_val2(n):
    val = 0
    for i in range(1,n+1):
        val = val + i / n
    #print("expect n,val",n,val)
    return val

n,k = map(int,input().split())
p = list(map(int,input().split()))
exp = [0]*n
for i in range(n):
    exp[i] = expect_val2(p[i])

max_val = max(p)
max_index = p.index(max_val)
ans = 0
for i in range(k):
    frm = max_index - i
    to = max_index + k-1 - i 
    #print("from,to",frm,to)
    if frm >= 0 and to <= n-1:
        #print("calc",frm,to)
        tmp = sum(exp[frm:to+1])
        if tmp >= ans:
            ans = tmp
    else:
        #print("skip")
        # do nothing
        ans
print(ans)

Submission status: Wrong Answer

Solution code:
# 0 
# max_val
def expect_val2(n):
    val = 0
    for i in range(1,n+1):
        val = val + i / n
    #print("expect n,val",n,val)
    return val

n,k = map(int,input().split())
p = list(map(int,input().split()))
exp = [0]*n
for i in range(n):
    exp[i] = expect_val2(p[i])

max_val = max(p)
max_index = p.index(max_val)
def expect_val(frm,to):
    val = 0
    for i in range(frm,to+1):
        val = val + exp[i]
    return val
ans = 0
for i in range(k):
    frm = max_index - i
    to = max_index + k-1 - i 
    #print("from,to",frm,to)
    if frm >= 0 and to <= n-1:
        #print("calc")
        tmp = expect_val(frm,to)
        if tmp >= ans:
            ans = tmp
    else:
        #print("skip")
        # do nothing
        ans
print(ans)

Submission status: Wrong Answer

Solution code:
# 0 
# max_val
n,k = map(int,input().split())
p = list(map(int,input().split()))
max_val = max(p)
max_index = p.index(max_val)
def expect_val2(n):
    val = 0
    for i in range(1,n+1):
        val = val + i / n
    #print("expect n,val",n,val)
    return val
def expect_val(frm,to):
    val = 0
    for i in range(frm,to+1):
        val = val + expect_val2(p[i])
    return val
ans = 0
for i in range(k):
    frm = max_index - i
    to = max_index + k-1 - i 
    #print("from,to",frm,to)
    if frm >= 0 and to <= n-1:
        #print("calc")
        tmp = expect_val(frm,to)
        if tmp >= ans:
            ans = tmp
    else:
        #print("skip")
        # do nothing
        ans
print(ans)

Submission status: Wrong Answer

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

maxexp = 0

kdice = [(1+p[i])/2 for i in range(n)]

for i in range(k):
    sumkdice = sum(kdice[i:i+k])
    if sumkdice > maxexp:
        maxexp = sumkdice

print(maxexp)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
e=[c[i] for i in range(b)]

for i in range(a-b):
    mn=min(e)
    if mn<=c[i]:
        for j in range(i-b,i):
            su=[]
            for n in range(b):
                su.append(c[n+j])
            if sum(su)>sum(e):
                e=su
print(sum([(e[i]+1)/2 for i in range(b)]))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
e=[c[i] for i in range(b)]
for i in range(b,a-b-1):
    mn=min(e)
    if mn<c[i]:
        for j in range(i-b+1,i):
            su=[]
            for n in range(b):
                su.append(c[n+j])
            if sum(su)>sum(e):
                e=su
print(sum([(e[i]+1)/2 for i in range(b)]))

Submission status: Wrong Answer

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

#そのサイコロの期待値の合計
e_list = []
for i in range(N):
    e_list.append((1+p_list[i])/2.0)

#累積和
s_list = []
for i in range(N):
    s_list.append(sum(e_list[:i+1]))

#隣接するk個の和
dst = 0
for i in range(N-K):
    s_sum = s_list[i+K] - s_list[i]
    if dst < s_sum:
        dst = s_sum
print(dst)

Submission status: Wrong Answer

Solution code:
input_line = list(map(int,input().split()))
input_int = list(map(int,input().split()))
result_list = []

for i in input_int[input_line[1] - 1:]:
    result_wari = sum(range(1,i+1)) / i
    result_list.append(float(result_wari))
    result = sum(result_list)

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

Submission status: Wrong Answer

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

m = [(e + 1) / 2 for e in p]
for i in range(1, N):
    m[i] += m[i - 1]

result = 0
for i in range(N - K):
    t = m[K - 1 + i] - m[i]
    if t > result:
        result = t
print(result)

Submission status: Wrong Answer

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

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

for i in range(k, n):
    ans = max(ans, ans + (p[i] + 1) / 2 - (p[i - k] + 1) / 2)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
 
def S(n):
  return n * (n + 1) // 2
 
b = 0
s = sum(p[:k])
M = max(p[:k])
for i in range(k, n):
  m = max(M, p[i])
  tmp = s - p[i - k] + p[i]
  if tmp > s:
    s = tmp
    b = i - k + 1
  if tmp == s and m != M:
    M = m
    s = tmp
    b = i - k + 1
    
    
ans = 0
for i in range(b, b + k):
  ans += S(p[i]) / p[i]
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0.0
max = 0.0
for j in range(0, N):
  sum += float(a[j])
  if j > K - 1:
    sum -= float(a[j - K])
    if max < sum:
      max = sum
print ((float(a[0]) + 1.0 ) / 2 if N == 1 else (max + float(K)) / 2)

Submission status: Wrong Answer

Solution code:
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0.0
max = 0.0
for j in range(0, N):
    sum += float(a[j])
    if j > K - 1:
      sum -= float(a[j - K])
      if max < sum:
        max = sum
print ((max + K) / 2)

Submission status: Wrong Answer

Solution code:
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0
max = 0
for j in range(0, N):
    sum += int(a[j])
    if j > K - 1:
      sum -= int(a[j - K])
      if max < sum:
        max = sum
e = (max + K) / 2 if (max + K) % 2 == 0 else str(int((max + K - 1) / 2)) + '.5'
print (e)

Submission status: Wrong Answer

Solution code:
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0
max = 0
for j in range(0, N):
    sum += int(a[j])
    if j > K - 1:
      sum -= int(a[j - K])
      if max < sum:
        max = sum
print ((max + K) / 2)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
p = list(map(int, input().split()))
ans = []
for i in range(len(p)):
    ans.append(p[i:i+4])
else:
    mx = max(ans, key=sum)
    ans2 = 0
    for j in range(len(mx)):
        for k in range(1,mx[j]+1) :
            ans2 += k/mx[j]

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

Submission status: Wrong Answer

Solution code:
N=2*10**5+7
n,k=map(int,input().split())
List=list(map(float,input().split()))
for i in range(n):
    List[i]=(1+List[i])/2
for i in range(1,n):
    List[i]+=List[i-1]
ans=0.0
for i in range(0,n-k+1):
    ans=max(ans,List[i+k-1]-List[max(0,i-1)])
print("{:.12f}".format(ans))

Submission status: Wrong Answer

Solution code:
N=2*10**5+7
n,k=map(int,input().split())
List=list(map(float,input().split()))
for i in range(n):
    List[i]=(1+List[i])/2
for i in range(1,n):
    List[i]+=List[i-1]
ans=0.0
for i in range(0,n-k+1):
    ans=max(ans,List[i+k-1]-List[max(0,i-1)])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#そのサイコロの期待値の合計
e_list = []
for i in range(N):
    e_list.append((1+p_list[i])/2.0)

#累積和
s_list = []
for i in range(N):
    s_list.append(sum(e_list[:i+1]))

#隣接するk個の和
dst = 0
for i in range(N-K+1):
    s_sum = s_list[i+K-1] - s_list[i]
    if dst < s_sum:
        dst = s_sum
print(dst)

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = 0
s = sum(input_list[:k])

for i in range(1, n-k+1):
  s = s - input_list[i-1] + input_list[i+k-1]
  maximum = max(maximum, s)

print( (maximum + k) / 2 )

Submission status: Wrong Answer

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

dst = 0

for i in range(N-K+1):
    print("i : {}".format(i))
    p_sum = 0
    for j in range(K):
        p = p_list[i+j]
        print("p : {}".format(p))
        p_sum += ( p/2 * (1+p)) / p
    if p_sum > dst:
        dst = p_sum
    
print(dst)

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = 0
for i in range(n-k):
  maximum = max(maximum, sum(input_list[i:i+k]))

print( (maximum + k) / 2 )

Submission status: Wrong Answer

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

dst = 0

for i in range(N-K+1):
  p_sum = 0
  for j in range(K):
    p = p_list[j]
    p_sum += p/2 * (1+p)
  if p_sum > dst:
    dst = p_sum
    
print(dst)

Submission status: Wrong Answer

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

def expectation(x):
    expectation_v = 0
    for i in range(1,x+1):
        expectation_v += i
    expectation_v /= x
    return expectation_v

for i in range(1,k+1):
    ans += expectation(p[-i])
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
dice_list = [int(s) for s in input().rstrip().split(' ')]
ex_list = (np.array(input().rstrip().split(' '), dtype=np.float32) + 1) / 2

print(np.max(np.array([np.mean(ex_list[i:i+dice_list[1]]) for i in range(dice_list[0] - dice_list[1] + 1)])))

Submission status: Wrong Answer

Solution code:
import numpy as np
dice_list = [int(s) for s in input().rstrip().split(' ')]
ex_list = (np.array(input().rstrip().split(' '), dtype=np.float32) + 1) / 2
length = dice_list[0]
t_len = dice_list[1]
max_avg = 0
for i in range(length - t_len + 1):
  avg = np.mean(ex_list[i:i+t_len])
  if max_avg < avg:
    max_avg = avg
print(max_avg)

Submission status: Wrong Answer

Solution code:
dice_list = [int(s) for s in input().rstrip().split(' ')]
expected_list = [(int(s) + 1) / 2 for s in input().rstrip().split(' ')]
length = dice_list[0]
t_len = dice_list[1]	
print(max([sum(expected_list[i:i+t_len]) / t_len for i, num in enumerate(expected_list) if i + t_len <= length]))

Submission status: Wrong Answer

Solution code:
def get_expected_value(max_num):
  return (max_num + 1) / 2
    
dice_list = [int(s) for s in input().rstrip().split(' ')]
expected_list = [(int(s) + 1) / 2 for s in input().rstrip().split(' ')]
 
t_len = dice_list[1]
print(max([sum(expected_list[i:i+t_len]) / t_len for i, num in enumerate(expected_list)]))

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    li = list(map(int,input().split()))
    wk = list(map(lambda x:(x+1)/2,li))
    kai = []

    for x in range(0,n-k+1):
        kai.append(sum(wk[x+1:x+k+1]))
    print(max(kai))

main()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
wk = list(map(lambda x:(x+1)/2,li))
kai = []

for x in range(0,n-k+1):
    kai.append(sum(wk[x+1:x+k+1]))
print(max(kai))

Submission status: Wrong Answer

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

    bigNumber = 0
    number = sum(p[0:y])

    for i in range(x-y):

        number = number - p[i] + p[i+y]

        if number > bigNumber:
            bigNumber = number

    print((bigNumber + y) / 2)

main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = [(p+1)/2 for p in list(map(int,input().split()))]

    S = [p_list[0]]

    maxs = 0

    for p in p_list[1:K]:
        S.append(S[-1] + p)

    for p in p_list[K::]:
        S.append(S[-1] + p)
        
        kitaichi = S[-1] - S[-1-K]

        if(maxs < kitaichi):
            maxs = kitaichi


    print(maxs)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
L = [(x+1)/2 for x in P]

tmp = sum(L[:K])
for i in range (N-K):
    nxt = tmp + L[K+i] - L[i]
    tmp = max(nxt, tmp)

print(tmp)

Submission status: Wrong Answer

Solution code:
# import numpy as np

def cal_ans(x):
    ans = (x+1)/2
    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 = []
S = [0]
for i in range(n):
    S.append(S[i]+p[i])
print(p)
print(S)
# for i in range(n-k+1):
#     ans_list.append(sum(p[i:i+k]))
t_len = len(S)
ans1 = 0
for i in range(t_len - k):
    if ans1 < S[i+k]-S[i]:
        ans1 = S[i+k]-S[i]
print(ans1)
# ans = 0
# for i in range(k):
#     ans += (ans_list[i]*(ans_list[i]+1)/2)/ans_list[i]
#     # print((ans_list[i]*(ans_list[i]+1)/2))
# print(ans)

Submission status: Wrong Answer

Solution code:
#ABC154D
import sys

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

for i in range(n+1-k):
    sum(p[i:i+k])

Submission status: Wrong Answer

Solution code:
#ABC154D
import sys

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

for i in range(n+1-k):
    print(p[i:i+k])

Submission status: Wrong Answer

Solution code:
N, K = input().split()
P = input().split()
max_sum = 0
for i in range(int(N)-int(K) + 1):
  sum = 0
  for k in range(i, i + int(K)):
    print(k)
    p = int(P[k])
    sum += (p / 2) + 0.5
    if max_sum < sum:
      max_sum = sum
print(float(max_sum))

Submission status: Wrong Answer

Solution code:
N, K = input().split()
P = input().split()
max_sum = 0
for i in range(int(N)-int(K)):
  sum = 0
  for k in range(i, i + int(K)):
    p = int(P[k])
    sum += (p / 2) + 0.5
    if max_sum < sum:
      max_sum = sum
print(max_sum)

Submission status: Wrong Answer

Solution code:
N, K = input().split()
P = input().split()
P.sort(reverse=True)
sum = 0
for k in range(int(K)):
  p = int(P[k])
  sum += (p / 2) + 0.5
print(sum)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse=True)
c = l[:b]
f = (sum(c)+b)/2
print(c)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse=True)
c = l[:b-1]
f = (sum(c)+b)/2
print(f)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
 
dice = list(map(int, input().split()))
a = 0
b = 0
 
a = sum(dice[0: k])
b = sum(dice[0: k])
 
res = 0
ll = 0
s = 0
mmm = range(k, len(dice))
for i in mmm:
    a += dice[i]
    a -= dice[i - k]
    if a > b:
        b = a
 
res = (a + k) /2
 
print(res)