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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

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

p = np.array(p)
p = np.cumsum(p)

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

ans = (ans + K) / Decimal(2.0)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = np.array(p)
p = np.cumsum(p)

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

ans = (ans + K) / 2.0
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = np.array(p)
p = np.cumsum(p)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

N, K = map(int, input().split())
p = np.array(list(map(lambda x: (int(x) + 1) / Decimal(2), input().split())))

p = np.cumsum(p)

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

print(ans)

Submission status: Wrong Answer

Solution code:
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(1 + p) / 2 for p in p_list]
max_v = sum(e_list[:k])
ret = max_v
#print(e_list, e_list[:k])
for i in range(n - k):
  calc = ret - e_list[i] + e_list[i + k]
  max_v = max(ret, calc)
  ret = calc
#  print(ret, e_list[i], e_list[i + k], calc)
print(max_v)

Submission status: Wrong Answer

Solution code:
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(1 + p) / 2 for p in p_list]
max_v = sum(e_list[:k])
ret = max_v
print(e_list, e_list[:k])
for i in range(n - k):
  calc = ret - e_list[i] + e_list[i + k]
  max_v = max(ret, calc)
  ret = calc
#  print(ret, e_list[i], e_list[i + k], calc)
print(max_v)

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

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

if N==1:
    print((p.max() + 1) / Decimal(2))
else:
    p = np.cumsum(p)

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

    ans = (ans + K) / Decimal(2)

    print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

p = list(accumulate(p))

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

ans = (ans + K) / 2.0

print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
from itertools import accumulate

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

p = list(accumulate(p))

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

ans = (ans + K) / Decimal(2)

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

p = list(accumulate(p))

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

ans = (ans + K) / 2

print(ans)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

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

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


max_sum = 0
temp_sum = 0

#最初の一組目を計算
for j in range(k):
    temp_sum += ((p[j] + 1) * p[j] / 2) / p[j]

#2組目以降を計算
for i in range(1,n-k+1):
    temp_sum = temp_sum - ((p[i-1] + 1) * p[i-1] / 2) / p[i-1] + ((p[i+k-1] + 1) * p[i+k-1] / 2) / p[i+k-1]

    if temp_sum > max_sum:
        max_sum = temp_sum
    

print(float(max_sum))




#n,k = map(int,input().split())
#
#p = list(map(int,input().split()))
#
#max_sum = 0#for j in range(k):
#    result += ((p[max_where + j] + 1) * p[max_where + j] / 2) / p[max_where + j]
#max_where = 0
#
##pi ~ pi+2の合計が最大のものが期待値も最大になる。
#for i in range(0,n-k+1):
#    temp_sum = sum(p[i:i+k])
#    if temp_sum > max_sum:
#        max_sum = temp_sum
#        max_where = i
#
#result = 0
#

#
#print(result)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

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

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


max_sum = 0
temp_sum = 0

#最初の一組目を計算
for j in range(k):
    temp_sum += ((p[j] + 1) * p[j] / 2) / p[j]

#2組目以降を計算
for i in range(1,n-k+1):
    temp_sum = temp_sum - ((p[i-1] + 1) * p[i-1] / 2) / p[i-1] + ((p[i+k-1] + 1) * p[i+k-1] / 2) / p[i+k-1]

    if temp_sum > max_sum:
        max_sum = temp_sum
    

print(max_sum)




#n,k = map(int,input().split())
#
#p = list(map(int,input().split()))
#
#max_sum = 0#for j in range(k):
#    result += ((p[max_where + j] + 1) * p[max_where + j] / 2) / p[max_where + j]
#max_where = 0
#
##pi ~ pi+2の合計が最大のものが期待値も最大になる。
#for i in range(0,n-k+1):
#    temp_sum = sum(p[i:i+k])
#    if temp_sum > max_sum:
#        max_sum = temp_sum
#        max_where = i
#
#result = 0
#

#
#print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n,k = readInts()
p = readInts()

s = []
s.append((p[0]+1)/2)

for i in range(1,n):
	s.append(s[-1]+(p[i]+1)/2)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n,k = readInts()
p = readInts()

s = []
s.append((p[0]+1)/2)

for i in range(1,n):
	s.append(s[-1]+(p[i]+1)/2)

ans = 0
#print(s)
for i in range(n-k):
	ans = max(ans,s[i+k]-s[i])

print(ans)

Submission status: Wrong Answer

Solution code:
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(1 + p) / 2 for p in p_list]
max_v = sum(e_list[:k])
ret = max_v
for i in range(n - k):
  calc = ret - e_list[i] + e_list[i + k]
  max_v = max(ret, calc)
  ret = calc
print(max_v)

Submission status: Wrong Answer

Solution code:
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(1 + p) / 2 for p in p_list]
max_v = sum(e_list[:k])
ret = max_v
print(e_list, e_list[:k])
for i in range(n - k):
  calc = ret - e_list[i] + e_list[i + k]
  max_v = max(ret, calc)
  ret = calc
print(max_v)

Submission status: Wrong Answer

Solution code:
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
total = []
for i in range(n - k + 1):
  print(i, p_list[i:k+i])
  total.append((sum(p_list[i:k+i]) + k) / 2)
print(max(total))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
p = nl()

def exp(num):
  ret = (1+num)/2
  return ret

mx=0

pp = list(map(exp,p))
pd = [0]*(n+1)

for i in range(1,n):
  pd[i] = pd[i-1] + pp[i]


for i in range(n-k+1):
  mx = max(pd[i+k]-pd[i],mx)
  
print(mx)

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
p = nl()

def exp(num):
  ret = (1+num)/2
  return ret

mx=0

pp = list(map(exp,p))
pd = [0]*(n+1)
pd[0] = pp[0]

for i in range(1,n):
  pd[i] = pd[i-1] + pp[i]


for i in range(n-k+1):
  mx = max(pd[i+k]-pd[i],mx)
print(mx)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
f=lambda x:0.5*(x+1)
p=list(map(f,p))
t=[0]*n
t[0]=p[0]
for i in range(1,n):
    t[i]=t[i-1]+p[i]
ans=0
for i in range(n-k):
    ans=max(ans,t[i+k]-t[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
f=lambda x:0.5*(x+1)
p=sorted(list(map(f,p)))
print(sum(p[-k:]))

Submission status: Wrong Answer

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

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

score = 0
for i in range(save,save+k):
    score += (1+p[i])/2 
print(score)

Submission status: Wrong Answer

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    answer = sum(p[0:K])
    r = answer
    for i in range(N-K):
        answer = answer - p[i] + p[i+K]
        print(answer)
        r = max(r, answer)
    print((r+K)/2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

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

sume = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        sume[i] = e[i]
    else:
        sume[i] = sume[i-1]+e[i]

ans = []
for i in range(n-k+1):
    if i == 0:
        ans.append(sume[i])
    else:
        ans.append(sume[i+k-1]-sume[i-1])   

print("%.12f"%max(ans))

Submission status: Wrong Answer

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    answer = sum(p[0:K])
    r = answer
    for i in range(N-K):
        answer = answer - p[i] + p[i+K]
        r = max(r, answer)
    print((answer+K)/2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

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

sume = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        sume[i] = e[i]
    else:
        sume[i] = sume[i-1]+e[i]

ans = []
for i in range(n-k+1):
    if i == 0:
        ans.append(sume[i])
    else:
        ans.append(sume[i+k-1]-sume[i-1])   

print(max(ans))

Submission status: Wrong Answer

Solution code:
import itertools


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

    P = [(1 + p) / 2 for p in P]
    accumulate_P = list(itertools.accumulate(P))

    ans = 0
    for ii in range(1, N - K):
        range_sum_P = accumulate_P[ii + K] - accumulate_P[ii]
        ans = max(ans, range_sum_P)

    print(ans)

resolve()

Submission status: Wrong Answer

Solution code:
import itertools


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

    P = [(1 + p) / 2 for p in P]
    accumulate_P = [0] + list(itertools.accumulate(P))

    ans = 0
    for ii in range(N - K):
        range_sum_P = accumulate_P[ii + K] - accumulate_P[ii]
        ans = max(ans, range_sum_P)

    print(ans)

resolve()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
total = [0] * n
total[0] = sum(range(1, p[0] + 1)) / p[0]
max_value = 0
for i in range(1, n):
    total[i] = total[i - 1] + sum(range(1, p[i] + 1)) / p[i]
    if i == k - 1:
        max_value = total[i]
    elif i >= k:
        max_value = max(max_value, total[i] - total[i - k])
print(max_value)

Submission status: Wrong Answer

Solution code:
import itertools


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

    for i in range(N):
        P[i] = sum(range(1, P[i] + 1)) / P[i]

    accumulate_P = list(itertools.accumulate(P))

    ans = 0
    for ii in range(N - K):
        range_sum_P = accumulate_P[ii + K] - accumulate_P[ii]
        ans = max(ans, range_sum_P)

    print(ans)
    

resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
s = sum(p[0:k])
s_max = 0
for i in range(n-k):
    s = s-p[i] + p[i+k]
    s_max = max(s_max,s)
if s_max % 2 == 0:
    print(ex_even(s_max) + 0.5*(k-1))
else:
    print(ex_odd(s_max) + 0.5*(k-1))

Submission status: Wrong Answer

Solution code:
from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
c_max = 0
for i in range(1,n+1):
    if p[i-1] % 2 == 0:
        ex = ex_even(p[i-1])
        if ex > q[0]:
            c_max = max(c_max, sum(q))
        q.popleft()
        q.append(ex)
    else:
        ex = ex_odd(p[i-1])
        if ex > q[0]:
            c_max = max(c_max, sum(q))
        q.popleft()
        q.append(ex)
print(c_max)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
r = 0
s = sum(p[0:K])

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

Submission status: Wrong Answer

Solution code:
n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*n
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i]=s
for i in range(len(anslist)):
    if i==0:
        z=sumlist[k-1]
        anslist[i]=z
    else:
        z=sumlist[i+k-1]-sumlist[i]
        anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)

Submission status: Wrong Answer

Solution code:
n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*n
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i]=s
for i in range(len(anslist)):
    if i==0:
        z=sumlist[k-1]
        anslist[i]=z
    else:
        z=sumlist[i+k-1]-sumlist[i]
        anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
p=list(map(int, input().split()))
ksum = sum(p[0:k])
ans = kans = ksum/2 + k*0.5
for i in range(n-k):
    print(p[i])
    ksum = ksum -p[i] +p[i+k]
    kans = ksum/2 + k*0.5
    if ans < kans:
        ans = kans
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
p=list(map(int, input().split()))
ans = 0.0
ksum = sum(p[0:k])
kans = ksum/2 + k*0.5
for i in range(n-k):
    ksum = ksum -p[i] +p[i+k]
    kans = ksum/2 + k*0.5
    if ans < kans:
        ans = kans
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
e = [(n+1)/2 for n in p]
now = sum(e[0:K])
ans = now
if N == 1 and K==1:
  print(e[0]/2)
  exit()

for i in range(1, N-K+1):
  now -= e[i-1]
  now += e[i+K-1]
  ans = max(ans, now)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    answer = 0
    means = list(map(lambda x: (1+x)/2, p))
    sum_list = [sum(means[:i]) for i in range(N+1)]
    for i in range(K-1, N):
        check = sum_list[i]-sum_list[i-K]
        if answer <= check:
            answer = check
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, k = inpl()
p = inpl()
tmp = sum([p[i] for i in range(k)])
maxval = 0
maxidx = -1
for i in range(n - k + 1):
    tmp += -p[i] + p[i + k - 1]
    if maxval < tmp:
        maxval = tmp
        maxidx = i

ans = sum([(p[i] + 1) / 2.0 for i in range(maxidx, maxidx + k)])
print(ans)

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n,k = map(int,input().strip().split())      # 1 <= k <= n <= 2*10^5
    p = list(map(lambda n: Fraction( (int(n)+1),2 ), input().strip().split())) # p[i] <= 10^3

    xsum=sum(p[0:k]) # 0 <= i < k
    ans=0
    for i in range(k,n):    # k <= i < n
        xsum = xsum + p[i] - p[i-k]
        ans = max(ans,xsum)
    print(float(ans))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
L = []
n = 0
l = 0
 
for p in range(N-K+1):
  for q in range(K):
    for r in range(D[p+q]+1):
      n = n + r
    f = n/D[p+q]
    l = l + f
    n = 0
  L.append(l)
  l = 0

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
kset = 0
for j in range(k):
    kset += p[j]

max = -10000
if n != k:
    for l in range(n-k):
        if kset >= max:
            max = kset
        kset = kset - p[l] + p[l+k]
else:
    max = kset
print(max)

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

kset = 0
for j in range(k):
    kset += p[j] 

max = -10000

if n != k:
    for l in range(n-k):
        if kset > max:
            max = kset
        kset = kset - p[l] + p[l+k]
else:
    max = kset
    
print(max)

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

kset = 0
for j in range(k):
    kset += p[j] 

max = -10000
for l in range(n-k):
    if kset > max:
        max = kset
    kset = kset - p[l] + p[l+k]

print(max)

Submission status: Wrong Answer

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

D = dict.fromkeys(P, 0)
for key in D.keys():
    D[key] = sum([j for j in range(1, key + 1)]) / key
C = [D[p] for p in P]
print(C)

ans = 0.0
for i in range(0, n - k + 1):
    tmp = sum(c for c in C[i: i + k])
    ans = max(tmp, ans)
print(ans)

Submission status: Wrong Answer

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

for i in range(n - k):
    ev = sum(p[i + 1:i + k + 1])
    if(cnt < ev):
        cnt = ev
  
print(cnt / 2 + 0.5 * k )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# D - Dice in Line

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

Q = [0] * N
for i in range(N):
    q = ((1 + P[i]) * P[i] / 2) / P[i]
    Q[i] = Q[i - 1] + q if 0 < i else q

mx = 0
for i in range(N - K):
    mx = max(mx, Q[i + K] - Q[i])

print(mx)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = -1
for i in range(n):
    if i + k >= n: break
    ans = max(ans, pe_list[i+k]-pe_list[i])
print(ans)

Submission status: Wrong Answer

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

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

m=0
for i in range(n-k+1):
    m = max(m,sum(p[i:i+k]))
    if sum(p[i:i+k])==m:
        ans_i = i
        break
ans=0
for i in range(ans_i,ans_i+k):
    ans += (p[i]+1)/2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def calc_ex(x):
    return  x/2 + 0.5
p_ = list(map(calc_ex,p_))

cnt,res =0,0
for i in range(2,n):
    cnt = sum(p_[i-k+1:i+1])
    res = max(cnt,res)
print(res)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


def main():
    n, k = map(int, stdin.readline().split())
    p = list(map(int, stdin.readline().split()))

    sp = [0] * 1001

    for i in range(1, 1001):
        sp[i] = sum(range(i + 1)) / i

    summary = [0] * n
    summary[0] = sp[p[0]]
    for i in range(1, n):
        summary[i] = summary[i - 1] + sp[p[i]]

    max = 0
    for i in range(k, n):
        tmp = summary[i] - summary[i - k]
        if tmp > max:
            max = tmp
    print(max)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

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

p_=[]
for i in range(len(p)):
  p_.append((1+p[i])/2)
print(p_)
 
import itertools
c=list(itertools.accumulate(p_))
print(c)
ans=0
if N!=K:
  
  for i in range(0,N-K):
    s=c[i+K]-c[i]
    ans=max(ans,s)
else:
  ans=c[K-1]
print(ans)

Submission status: Wrong Answer

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

p_=[]
for i in range(len(p)):
  p_.append((1+p[i])/2)
 
import itertools
c=list(itertools.accumulate(p_))

ans=0
if N!=K:
  
  for i in range(0,N-K):
    s=c[i+K]-c[i]
    ans=max(ans,s)
else:
  ans=c[K-1]-c[0]
print(ans)

Submission status: Wrong Answer

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

p_=[]
for i in range(len(p)):
  p_.append((1+p[i])/2)
 
import itertools
c=list(itertools.accumulate(p_))

ans=0
for i in range(N-K):
  s=c[i+K]-c[i]
  ans=max(ans,s)
print(ans)