AtCoder Beginner Contest 154 - Dice in Line

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-----
5 3
1 2 2 4 5

-----Sample Output-----
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.

Source: atcoder | Difficulty: MEDIUM


Solutions:
(N, K) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = s
for i in range(N - K):
	s = s - p[i] + p[K + i]
	if m < s:
		m = s
print((m + K) / 2)


(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 = s[k - 1]
for i in range(n - k):
	ans = max(ans, s[i + k] - s[i])
print((ans + k) / 2)


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


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


(N, K) = map(int, input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF] * 1001

def expectationF(num):
	if expList[num] == INF:
		exp = 0
		for i in range(1, num + 1):
			exp += i / num
		expList[num] = exp
	return expList[num]
res = 0
mid = 0
midList = []
for i in range(N):
	if i >= 1:
		midList.append(expectationF(List[i]) + midList[i - 1])
	else:
		midList.append(expectationF(List[i]))
m = K - 1
for j in range(N - m):
	if j == 0:
		mid = midList[j + m]
	else:
		mid = midList[j + m] - midList[j - 1]
	res = max(res, mid)
print(res)


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


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
s = sum(P[:K])
m = s
for i in range(N - K):
	s += P[i + K] - P[i]
	m = max(m, s)
print((m + K) / 2)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
(r, x) = (0, 0)
for i in range(N):
	x += 1 + P[i]
	if K <= i:
		x -= 1 + P[i - K]
	r = max(r, x)
print(r / 2)


(N, K) = list(map(int, input().split()))
A = list([int(s) + 1 for s in input().split()])
ans = sum(A[0:K])
tmp = ans
for i in range(N - K):
	tmp += A[i + K] - A[i]
	ans = max(ans, tmp)
print(ans / 2)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
mx = sum(p[:K])
cur = mx
for i in range(N - K):
	cur = cur - p[i] + p[i + K]
	mx = max(mx, cur)
ans = (mx + K) / 2
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
l = sum(P[0:K])
k = l
for i in range(N - K):
	l = l - P[i] + P[i + K]
	if l > k:
		k = l
print((k + K) / 2)


def resolve():
	(n, k) = map(int, input().split())
	p = tuple(map(int, input().split()))
	s = [(i + 1) / 2 for i in p]
	a = sum(s[:k])
	ans = a
	for i in range(1, n - k + 1):
		a = a - s[i - 1] + s[k + i - 1]
		ans = max(ans, a)
	print(ans)
resolve()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:k])
ret = s
for i in range(k, n):
	s += p[i] - p[i - k]
	ret = max(ret, s)
print((ret + k) / 2.0)


def main():
	(N, K) = [int(x) for x in input().split(' ')]
	P = [int(p) for p in input().split(' ')]
	E = [sum(P[:K])]
	for i in range(N - K):
		E.append(E[-1] - P[i] + P[i + K])
	print((max(E) + K) / 2)
main()


(n, k) = map(int, input().split())
a = [(int(i) + 1) / 2 for i in input().split()]
ex = 0
for i in range(k):
	ex += a[i]
ans = ex
for i in range(k, n):
	ex += a[i] - a[i - k]
	if ans < ex:
		ans = ex
print(ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
for i in range(n - k):
	tmp -= p[i]
	tmp += p[i + k]
	res = max(res, tmp)
print((res + k) / 2)


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


inp = input().split(' ')
n = int(inp[0])
k = int(inp[1])
nums = input().split(' ')
nums = [int(x) for x in nums]
sums = [0]
for x in nums:
	sums += [x + sums[-1]]
m = 0
for i in range(0, n - k + 1):
	m = max(m, sums[i + k] - sums[i])
print((m + k) / 2)


(n, k) = map(int, input().split())
p = [int(x) for x in input().split()]
s = 0
for c in range(k):
	s += p[c]
t = s
for c in range(n - k):
	t += p[c + k] - p[c]
	if t > s:
		s = t
print((s + k) / 2)


(N, K) = map(int, input().split())
P = [(int(x) + 1) / 2 for x in input().split()]
total = ans = sum(P[:K])
for n in range(K, N):
	total += P[n] - P[n - K]
	ans = max(ans, total)
print(ans)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
l = 0
for i in range(K):
	l = l + (p[i] + 1) / 2
t = l
for i in range(N - K):
	l = l - (p[i] + 1) / 2 + (p[i + K] + 1) / 2
	if l > t:
		t = l
print(t)


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


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


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
B = sum(P[0:K])
M = B
for i in range(K, N):
	B = B - P[i - K] + P[i]
	M = max(M, B)
print((M + K) / 2)


(N, K) = map(int, input().split())
P = [1 + (int(p) - 1) * 0.5 for p in input().split()]
tmp = sum(P[:K])
ans = tmp
for i in range(N - K):
	tmp += P[K + i] - P[i]
	if tmp > ans:
		ans = tmp
print(ans)


(N, K) = map(int, input().split())
t = list(input().split())
s = [int(n) for n in t]
max = x = sum(s[:K])
for i in range(N - K):
	x += s[K + i] - s[i]
	if max < x:
		max = x
print((max + K) / 2)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
E = [0]
for x in lst:
	E.append((1 + x) / 2 + E[-1])
s = 0
for i in range(n + 1 - k):
	if s < E[i + k] - E[i]:
		s = E[i + k] - E[i]
print(s)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
a = 0
for j in range(K):
	a += (1 + p[j]) / 2
Max = a
for i in range(K, N):
	a = a + (p[i] - p[i - K]) / 2
	if Max < a:
		Max = a
print(Max)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
val = sum(li[:m])
ans = val
for i in range(m, n):
	val = val - li[i - m] + li[i]
	ans = max(ans, val)
print((ans + m) / 2)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
res = 0
sum = 0
for i in range(N):
	sum += A[i]
	if i - K >= 0:
		sum -= A[i - K]
	res = max(res, sum)
print(0.5 * (res + K))


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


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = [0]
for i in range(0, n - k):
	q.append(q[-1] + p[i + k] - p[i])
b = q.index(max(q))
s = 0
for i in range(b, b + k):
	s += p[i]
print((s + k) / 2)


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


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


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
s = 0
for i in range(k):
	s = s + A[i]
ans = s
for i in range(n - k):
	s = s - A[i] + A[k + i]
	if s > ans:
		ans = s
print((ans + k) / 2)


(n, k) = map(int, input().split())
P = list(map(int, input().split()))
now = sum(P[:k])
m = now
for i in range(n - k):
	now += P[k + i]
	now -= P[i]
	m = max(m, now)
E = (m + k) / 2
print(E)


A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sum(B[0:A[1]])
D = C
for i in range(A[1] - 1, A[0] - 1):
	D = D + B[i + 1] - B[i - A[1] + 1]
	C = max(C, D)
print((C + A[1]) / 2)


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


(N, K) = map(int, input().split())
p_list = list(map(int, input().split()))
p_list_E = []
p_list_E_temp = [1, 1.5, 2, 2.5, 3, 3.5]
for i in range(len(p_list)):
	p_list_E.append((p_list[i] + 1) * 0.5)
p_list_sum = [0]
for i in range(0, N):
	p_list_sum.append(p_list_sum[i] + p_list_E[i])
ans = 0
for i in range(K, N + 1):
	ans = max(ans, p_list_sum[i] - p_list_sum[i - K])
print(ans)


from functools import reduce
(n, k) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
tmp_max = sum([i / 2 + 0.5 for i in p[0:k]])
tmp = tmp_max
idx = 0
for i in range(1, len(p) - k + 1):
	tmp -= p[i - 1] / 2 + 0.5
	if i + k - 1 < len(p):
		tmp += p[i + k - 1] / 2 + 0.5
	tmp_max = max(tmp_max, tmp)
print(tmp_max)


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


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


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
x = sum(p[:K])
max_x = x
for i in range(K, N):
	x = x - p[i - K] + p[i]
	max_x = max(x, max_x)
print((max_x + K) / 2)


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


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


(n, k) = map(int, input().split())
P = list(map(int, input().split()))
P_ac = [sum(P[:k])]
for i in range(n - k):
	P_ac.append(P_ac[-1] - P[i] + P[i + k])
print((max(P_ac) + k) / 2)


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


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


(n, k) = map(int, input().split())
p = list(map(lambda x: (int(x) + 1) / 2, input().split()))
t = sum(p[:k])
ans = t
for i in range(k, n):
	t += p[i] - p[i - k]
	if ans < t:
		ans = t
print(ans)


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


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
S = sum(p[:K])
T = S
for i in range(N - K):
	S = S - p[i] + p[i + K]
	T = max(T, S)
print((T + K) / 2)


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


(N, K) = list(map(int, input().split()))
S = list(map(int, input().split()))
result = [(sum(S[:K]) + K) / 2]
for i in range(N - K):
	result.append(result[-1] + S[i + K] / 2 - S[i] / 2)
print(max(result))


(n, k) = [int(i) for i in input().split()]
p = [(int(i) + 1) / 2 for i in input().split()]
ans = 0
sum_num = sum(p[:k])
for i in range(n - k + 1):
	if i == 0:
		sum_num = sum(p[:k])
	else:
		sum_num += p[i + k - 1] - p[i - 1]
	ans = max(ans, sum_num)
print(ans)


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


(N, K) = map(int, input().split())
P = list(map(lambda x: (int(x) + 1) / 2, input().split()))
s = sum(P[:K])
tmp = s
for i in range(K, N):
	tmp = tmp - P[i - K] + P[i]
	if tmp > s:
		s = tmp
print(s)


(N, K) = list(map(int, input().split()))
p = list(map(int, input().split()))
I = [0] * N
for i in range(N):
	I[i] = (p[i] + 1) / 2
S = sum(I[:K])
ans = S
l = 0
r = K
while r < N:
	S = S - I[l] + I[r]
	ans = max(ans, S)
	l += 1
	r += 1
print(ans)
return


def main():
	(N, K) = list(map(int, input().split()))
	(tmp, ans) = (0.0, 0.0)
	P = list(map(int, input().split()))
	for i in range(N):
		if i < K:
			tmp += P[i]
			ans = tmp
		else:
			tmp += P[i] - P[i - K]
			ans = max(ans, tmp)
	ans = (ans + K) / 2
	print(ans)

def __starting_point():
	main()
__starting_point()


import sys
from collections import deque, Counter, defaultdict
import bisect
import heapq
import math
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
inf = 10 ** 18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
mod = 998244353
(n, k) = rl()
p = rl()
sum_ = 0
(cum, ans, ser) = ([], [], [])
for i in range(1, 2000):
	sum_ += i
	cum.append(sum_ / i)
for i in p:
	ans.append(cum[i - 1])
cs = [0]
for i in range(n):
	cs.append(cs[i] + ans[i])
for i in range(n + 1 - k):
	ser.append(cs[i + k] - cs[i])
print(max(ser))


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


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
data = [0] * n
for i in range(n):
	data[i] = p[i] / 2 + float(0.5)
res = sum(data[0:k])
ans = sum(data[0:k])
for i in range(n - k):
	res -= data[i] - data[i + k]
	ans = max(ans, res)
print(ans)


(n, k) = map(int, input().split())
p = [(int(v) + 1) / 2 for v in input().split()]
e = [sum(p[:k])]
for i in range(n - k):
	e.append(e[-1] - p[i] + p[i + k])
print(max(e))


from itertools import accumulate
(n, k) = map(int, input().split())
p = [-~int(i) / 2 for i in input().split()]
a = [0] + list(accumulate(p))
print(max((j - i for (i, j) in zip(a, a[k:]))))


(n, k, *a) = map(int, open(0).read().split())
b = [q + 1 for q in a]
ans = sum(b[:k])
now = ans
for i in range(k, n):
	now = now + b[i] - b[i - k]
	ans = max(ans, now)
print(ans / 2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
l = [sum(p[:k])]
for i in range(n - k):
	l1 = l[i] - p[i] + p[i + k]
	l.append(l1)
print((max(l) + k) / 2)


(n, k) = map(int, input().split())
(*l,) = map(int, input().split())
a = sum(l[:k])
s = a
for i in range(k, n):
	a += l[i]
	a -= l[i - k]
	s = max([a, s])
print((s + k) / 2)


(N, K) = (int(a) for a in input().split())
p = list(((int(a) + 1) / 2 for a in input().split()))
s = [sum(p[:K])]
for i in range(N - K):
	s.append(s[-1] - p[i] + p[i + K])
print(max(s))


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


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

def ev(n):
	return n * (n + 1) / (2 * n)
q = [0]
for i in range(n):
	q.append(ev(p[i]))
	q[i + 1] = q[i] + ev(p[i])
tmp = 0
for j in range(n - k + 1):
	if tmp <= q[j + k] - q[j]:
		tmp = q[j + k] - q[j]
print(tmp)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
m = sum(p[:k])
q = m
for i in range(n - k):
	q = q - p[i] + p[i + k]
	if q > m:
		m = q
print((k + m) / 2)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
M = [sum(p[:K])]
for i in range(1, N - K + 1):
	tmp = M[-1] - p[i - 1] + p[i + K - 1]
	M.append(tmp)
ans = max(M) / 2 + K / 2
print(ans)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
res = 0
s = sum(p[:K])
for i in range(N - K + 1):
	res = max(res, (s + K) / 2)
	if i != N - K:
		s = s + p[i + K] - p[i]
print(res)


import math
ini = lambda : int(input())
inm = lambda : map(int, input().split())
inl = lambda : list(map(int, input().split()))
gcd = lambda x, y: gcd(y, x % y) if x % y else y

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def find(self, x):
		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 -self.parents[self.find(x)]

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

	def members(self, x):
		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()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
mod = 10 ** 9 + 7
sigma = lambda x: x * (x + 1) // 2
(n, k) = inm()
p = inl()
s = sum(p[:k])
c = s
d = 0
for i in range(k, n):
	s = s - p[i - k] + p[i]
	if c < s:
		c = s
		d = i - k + 1
ans = sum((sigma(x) / x for x in p[d:d + k]))
print(ans)


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


from itertools import accumulate
(n, k) = list(map(int, input().split()))
Pcum = [0] + list(accumulate(list(map(int, input().split()))))
ans = 0
for L in range(n):
	R = L + k
	if n < R:
		break
	cnt = (Pcum[R] - Pcum[L] + k) / 2
	if ans < cnt:
		ans = cnt
print(ans)


(N, K) = list(map(int, input().split()))
Ps = list(map(int, input().split()))
ruisekiwa = [0]
for P in Ps:
	ruisekiwa.append(P + ruisekiwa[-1])
ans = 0
for i in range(N - K + 1):
	ans = max(ans, (ruisekiwa[i + K] - ruisekiwa[i] + K) / 2)
print(ans)


(N, K) = map(int, input().split())
P = [(int(x) + 1) / 2 for x in input().split()]
Q = [0] * (N + 1)
for n in range(N):
	Q[n + 1] = Q[n] + P[n]
ans = 0
for n in range(K, N + 1):
	ans = max(ans, Q[n] - Q[n - K])
print(ans)


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


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
ss = []
ss.append(s)
for i in range(N - K):
	s = s - p[i] + p[i + K]
	ss.append(s)
print(K + (max(ss) - K) / 2)


def main():
	(n, k) = map(int, input().split())
	p_lst = list(map(int, input().split()))
	lst = []
	for i in range(n):
		lst.append((p_lst[i] + 1) / 2)
	tmp_sum = sum(lst[:k])
	maximum = tmp_sum
	for i in range(n - k):
		tmp_sum -= lst[i]
		tmp_sum += lst[i + k]
		maximum = max(maximum, tmp_sum)
	print(maximum)

def __starting_point():
	main()
__starting_point()


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


(n, k) = [int(i) for i in input().split()]
p = [(float(i) + 1) / 2 for i in input().split()]
tmp = [sum(p[:k])]
for i in range(1, n - k + 1):
	tmp.append(tmp[-1] - p[i - 1] + p[i + k - 1])
print(max(tmp))


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


from collections import deque
(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
kitai = [0] * 1000
tmp = 0
for i in range(1000):
	tmp += i + 1
	kitai[i] = tmp / (i + 1)
total_kitai = [0] * (n + 1)
tmp = 0
for i in range(n):
	tmp += kitai[p[i] - 1]
	total_kitai[i + 1] = tmp
ans = 0
for i in range(n - k + 1):
	ans = max(total_kitai[i + k] - total_kitai[i], ans)
print(ans)


(n, k, *p) = map(int, open(0).read().split())
m = sum(p[0:k])
ans = [m]
for i in range(k, n):
	m = m + p[i] - p[i - k]
	ans.append(m)
print(0.5 * (max(ans) + k))


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


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in range(K):
	ans += (P[i] + 1) / 2
tmp = ans
for i in range(K, N):
	tmp = tmp + (P[i] + 1) / 2 - (P[i - K] + 1) / 2
	ans = max(ans, tmp)
print(ans)


def expect(n):
	return (n + 1) / 2
nk = input().split()
N = int(nk[0])
K = int(nk[1])
p = input().split()
tmp = 0
for i in range(K):
	tmp += expect(int(p[i]))
tmpMax = tmp
for i in range(N - K):
	tmp -= expect(int(p[i]))
	tmp += expect(int(p[i + K]))
	tmpMax = max(tmpMax, tmp)
print(tmpMax)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
mx = sm = sum(P[:K])
for i in range(N - K):
	sm = sm + P[i + K] - P[i]
	mx = max(mx, sm)
print((mx + K) / 2)


(N, K) = map(int, input().split())
ds = list(map(int, input().split()))
sm = sum(ds[:K])
out = sm
for i in range(N - K):
	sm = sm - ds[i] + ds[i + K]
	out = max(out, sm)
print((out + K) / 2)


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
s = sum(l[:k])
ma = s
i = 0
while i + k < len(l):
	s -= l[i]
	s += l[i + k]
	ma = max(ma, s)
	i += 1
print((ma + k) / 2)


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np

def main():
	(n, k) = list(map(int, input().split()))
	p = np.array(read().split(), np.int32)
	p += 1
	pcum = np.zeros(n + 1, np.int32)
	pcum[1:] = p.cumsum()
	sum_k = pcum[k:] - pcum[:-k]
	print(sum_k.max() / 2)

def __starting_point():
	main()
__starting_point()


def rsum(n):
	return (n + 1) * (n // 2) + (n + 1) // 2 if n % 2 else (n + 1) * (n // 2)
(N, K) = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * N
for i in range(N):
	l[i] = rsum(p[i]) * (1 / p[i])
s = sum(l[0:K])
ans = 0
for i in range(N - K):
	ans = max(ans, s)
	s -= l[i]
	s += l[i + K]
print(max(ans, s))


from itertools import accumulate
(N, K) = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x) + 1) / 2.0, input().split())))
print(max([y - x for (x, y) in zip(ans, ans[K:])]))


nk = input().split()
n = int(nk[0])
k = int(nk[1])
p_s = input().split()
p = [int(s) for s in p_s]
max_val = 0
for i in range(0, k):
	max_val += p[i]
tmp = max_val
for i in range(k, len(p)):
	tmp = tmp - p[i - k] + p[i]
	if tmp > max_val:
		max_val = tmp
print(max_val / 2 + 0.5 * k)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
tot = 0
for p in P:
	tot += (p + 1) / 2
	E.append(tot)
m = 0
for i in range(N - (K - 1)):
	_ = E[i + K] - E[i]
	if _ > m:
		m = _
print(m)


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


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
m = s = sum(p[0:k])
for (p_old, p_new) in zip(p, p[k:]):
	s += p_new - p_old
	m = max(m, s)
print((m + k) / 2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
P1 = sum(p[:k])
ans = P1
for i in range(k, n):
	P1 += p[i] - p[i - k]
	if ans < P1:
		ans = P1
print((ans + k) / 2)


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


(N, K) = list(map(int, input().split()))
P = list(map(int, input().split()))
E = []
for i in range(N):
	E.append((P[i] + 1) / 2)
tnt = sum(E[:K])
ans = tnt
for i in range(N - K):
	tnt = tnt + E[K + i] - E[i]
	ans = max(ans, tnt)
print(ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
mu = [(a + 1) / 2 for a in p]
maxsum = sum(mu[:k])
now = maxsum
left = 0
right = k
while right < n:
	now = now + mu[right] - mu[left]
	if maxsum < now:
		maxsum = now
	left += 1
	right += 1
print(maxsum)


(N, K) = list(map(int, input().split()))
lst = list(map(int, input().split()))
n = sum(lst[:K])
m = n
for i in range(N - K):
	l = lst[i]
	r = lst[i + K]
	n = n + r - l
	if m < n:
		m = n
ans = (m + K) / 2
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
T = [0] * N
for i in range(N):
	P[i] = (1 + P[i]) / 2
if N == K:
	print(sum(P))
else:
	for i in range(1, N):
		P[i] += P[i - 1]
	for i in range(K, N):
		T[i] = P[i] - P[i - K]
	T = T[K:]
	print(max(T))


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
X = 0
for k in range(K):
	X += P[k]
Y = X
for n in range(1, N - K + 1):
	Y = Y + P[n + K - 1] - P[n - 1]
	X = max(X, Y)
print((X + K) / 2)


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


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a[:k])
mx = s
for i in range(k, n):
	s += a[i] - a[i - k]
	mx = max(mx, s)
print((mx + k) / 2)


(N, K) = map(int, input().split())
P = [0] + list(map(int, input().split()))
S = [0] * (N + 1)
for i in range(1, N + 1):
	S[i] = S[i - 1] + P[i]
M = -1
for j in range(N - K + 1):
	M = max(M, S[j + K] - S[j])
print((M + K) / 2)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
an = sum(l[:k])
ans = an
for i in range(k, n):
	an = an + l[i] - l[i - k]
	ans = max(ans, an)
print((ans + k) / 2)


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


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
maxs = s
for i in range(N - K):
	s = s - p[i] + p[K + i]
	maxs = max(maxs, s)
ans = (maxs + K) / 2
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
A = P[:K]
a = sum(A)
max = a
for i in range(N - K):
	a = a - P[i] + P[i + K]
	if max <= a:
		max = a
print((max + K) / 2.0)


from itertools import accumulate
(N, K) = map(int, input().split())
P = list(map(int, input().split()))
A = list(accumulate(P))
largest = A[K - 1]
point = 0
for i in range(K, N):
	if largest < A[i] - A[i - K]:
		largest = A[i] - A[i - K]
		point = i
ans = 0
for j in range(point - K + 1, point + 1):
	p = P[j]
	ans += (p + 1) * p / 2 / p
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
S = sum(P[:K])
M = S
for k in range(N - K):
	S = S - P[k] + P[k + K]
	if M < S:
		M = S
print((M + K) / 2)


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


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


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
sum1 = 0.0
for i in range(K):
	sum1 = (p[i] + 1) / 2.0 + sum1
sum2 = sum1
for i in range(N - K):
	sum1 = sum1 + (p[i + K] - p[i]) / 2.0
	if sum1 > sum2:
		sum2 = sum1
print(sum2)


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


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
for ii in range(n):
	b[ii] = (1 + a[ii]) / 2
temp = sum(b[0:k])
ans = temp
for ii in range(n - k):
	temp += b[ii + k] - b[ii]
	if temp > ans:
		ans = temp
print(ans)


(N, K) = map(int, input().split())
(*P,) = map(int, input().split())
ans = (sum(P[:K]) + K) / 2
now = ans
i = K
while i < N:
	now = now + (P[i] + 1) / 2 - (P[i - K] + 1) / 2
	ans = max(now, ans)
	i += 1
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
Q = sum(P[:K])
R = Q
for n in range(N - K):
	Q = Q - P[n] + P[n + K]
	R = max(Q, R)
print((R + K) / 2)


(N, K) = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
E = [0] * N
Elist = {}
for val in set(A):
	e = 0
	for i in range(1, val + 1):
		e += i / val
	Elist[val] = e
for i in range(N):
	E[i] = Elist[A[i]]
En = sum(E[:K])
Emax = En
for j in range(1, N - K + 1):
	En = En - E[j - 1] + E[j - 1 + K]
	Emax = max(Emax, En)
print(Emax)


import sys
(N, K) = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = [(1 + p) / 2 for p in P]
temp = sum(Q[:K])
ans = temp
for i in range(N):
	try:
		temp = temp - Q[i] + Q[i + K]
		ans = max(ans, temp)
	except:
		pass
else:
	print(ans)


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


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


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
m = 0
temp = 0
for i in range(N):
	temp += P[i]
	if i + 1 >= K:
		m = max(m, temp)
		temp -= P[i - K + 1]
print((m + K) / 2)


(n, k) = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
ans = 0
v = []
for a in aaa:
	v.append(a * (a + 1) / (2.0 * a))
current = 0
for i in range(n):
	current += v[i]
	if i >= k:
		current -= v[i - k]
	ans = max(ans, current)
print(ans)


def dice_expectation(p):
	return (1 + p) * p / 2 * (1 / p)
(n, k) = list(map(int, input().split()))
pp = [0] * (n + 1)
for (i, p) in enumerate(map(int, input().split())):
	pp[i + 1] = pp[i] + dice_expectation(p)
max = -1
for i in range(k, n + 1, 1):
	max = pp[i] - pp[i - k] if pp[i] - pp[i - k] > max else max
print(max)


(N, K) = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
s = m = sum(p[:K])
for i in range(K, N):
	s += p[i] - p[i - K]
	m = max(m, s)
print((m + K) / 2)


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


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


(N, K) = map(int, input().split())
l = list(map(int, input().split()))
c = sum(l[0:K])
ans = c
for i in range(N - K):
	c = c - l[i] + l[i + K]
	if c > ans:
		ans = c
print((ans + K) / 2)


import os, sys, re, math

def get_exp_value(number):
	if number == 0:
		return 0
	a = (number + 1) / number
	exp = a * (number // 2)
	if number % 2 != 0:
		exp += a / 2
	return exp
(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]
exps = [get_exp_value(i) for i in range(200001)]
s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
	s = s - P[i - K] + P[i]
	if s > max_sum:
		max_sum = s
		max_pos = i
answer = 0
for i in range(max_pos - K, max_pos):
	answer += exps[P[i + 1]]
print(answer)


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


nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]
p = [int(s) + 1 for s in input().split()]
l = [sum(p[:k])]
for x in range(n - k):
	l.append(l[x] - p[x] + p[x + k])
print(max(l) / 2)


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


(N, K) = [int(s) for s in input().split(' ')]
P = [int(s) for s in input().split(' ')]
s = []
a = sum(P[0:K])
s.append(a)
for (p0, p1) in zip(P, P[K:]):
	a = a - p0 + p1
	s.append(a)
print((max(s) + K) / 2)


from itertools import *
i = lambda f: map(f, input().split())
(n, k) = i(int)
p = [0] + list(accumulate(i(lambda x: -~int(x) / 2)))
print(max((p[i + k] - p[i] for i in range(n - k + 1))))


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
now = sum(p[:K])
t = [now]
for i in range(N - K):
	now += p[K + i] - p[i]
	t.append(now)
ma = (max(t) + K) / 2
print(ma)


(n, k) = map(int, input().split())
p = [(int(s) + 1) / 2 for s in input().split()]
l = [sum(p[:k])]
for i in range(n - k):
	l.append(l[i] - p[i] + p[i + k])
print(max(l))


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
M = [sum(P[:K]) / 2 + K / 2]
for i in range(1, N - K + 1):
	M.append(M[i - 1] - P[i - 1] / 2 + P[i - 1 + K] / 2)
print(max(M))


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
M = sum(P[0:K])
m = M
for i in range(0, N - K):
	m = m - P[i] + P[i + K]
	if m >= M:
		M = m
print((M + K) / 2.0)


(n, k) = map(int, input().split())
p = [(i + 1) / 2 for i in map(float, input().split())]
MAX = sum(p[0:k])
s = [MAX] * n
for i in range(0, n - k):
	s[i + 1] = p[i + k] + s[i] - p[i]
	MAX = max(MAX, s[i + 1])
print(MAX)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[0:K])
d = 0
e = 0
for i in range(N - K):
	d += p[i + K] - p[i]
	if d > e:
		e = d
s += e
print((s + 1 * K) / 2)


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


(N, K) = [int(x) for x in input().split()]
l = [(int(x) + 1) / 2 for x in input().split()]
t = sum(l[:K])
ans = t
for i in range(N - K):
	t = t - l[i] + l[K + i]
	ans = max(ans, t)
print(ans)


(N, K) = list(map(int, input().split()))
p = list(map(int, input().split()))
s = 0
hoge = 0
ans = 0
for i in range(K):
	s += p[i]
	temp = s
for j in range(N - K):
	s = s - p[j] + p[j + K]
	if temp < s:
		temp = s
		hoge = j + 1
for k in range(K):
	ans += (1 + p[hoge + k]) / 2
print(ans)


def main():
	(n, k) = map(int, input().split(' '))
	p = list(map(int, input().split(' ')))
	u = [0]
	v = []
	w = []
	for i in range(n):
		u.append(u[i] + p[i])
	for i in range(n - k + 1):
		w.append(u[k + i] - u[i])
	x = w.index(max(w))
	for i in range(k):
		v.append(p[x + i])
	a = 0
	for i in range(k):
		a += 1 + 0.5 * (v[i] - 1)
	print(a)

def __starting_point():
	main()
__starting_point()


def main():

	def expected_val(limit):
		return (1 + limit) / 2
	(N, K) = list(map(int, input().split()))
	P = [int(x) for x in input().split()]
	lst = [0]
	res = 0
	for p in P:
		res += expected_val(p)
		lst.append(res)
	ans = 0
	for i in range(N - K + 1):
		res = lst[i + K] - lst[i]
		ans = res if res > ans else ans
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k, *ps) = map(int, open(0).read().split())
dp = tmp = sum(ps[:k])
for i in range(1, n - k + 1):
	tmp = tmp - ps[i - 1] + ps[i + k - 1]
	dp = max(dp, tmp)
print((dp + k) / 2)


import numpy as np
(N, K) = map(int, input().split())
p = list(map(lambda x: (int(x) + 1) / 2, input().split()))
if N == K:
	print(sum(p))
else:
	cs = np.cumsum(p)
	m = []
	for i in range(N - K):
		m.append(cs[K + i] - cs[i])
	print(max(m))


(N, K) = list(map(int, input().split()))
P = list(map(float, input().split()))
p = [0]
for i in range(N):
	p.append(p[-1] + (P[i] + 1) / 2)
print(max((p[i + K] - p[i] for i in range(N - K + 1))))


(n, k) = map(int, input().split())
ps = list(map(int, input().split()))
tmp = sum(ps[:k])
res = tmp
for (p, s) in zip(ps, ps[k:]):
	tmp += s - p
	res = max(res, tmp)
print((res + k) / 2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
e = 0
for i in range(k):
	e += p[i]
f = e
for i in range(n - k):
	f = f - p[i] + p[i + k]
	e = max(e, f)
print((e + k) / 2)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
s = [0] * (N + 1)
for i in range(N):
	s[i + 1] = s[i] + P[i]
m = 0
midx = 0
for j in range(N - K + 1):
	v = s[j + K] - s[j]
	if v > m:
		m = v
		midx = j
E = 0
for k in range(midx, midx + K):
	x = P[k]
	E += 1 / x * (x * (x + 1) / 2)
print(E)


(n, k) = list(map(int, input().split()))
p = list(map(int, input().split()))
sample = []
for i in range(1, 1001):
	sample.append((1 + i) / 2)
kitaichi = []
for i in range(n):
	kitaichi.append(sample[p[i] - 1])
maxkitaichi = 0
sum = 0
for i in range(k):
	maxkitaichi += kitaichi[i]
	sum += kitaichi[i]
for i in range(1, n - k + 1):
	sum = sum + kitaichi[i + k - 1] - kitaichi[i - 1]
	if sum >= maxkitaichi:
		maxkitaichi = sum
print(maxkitaichi)


import itertools
(N, K) = map(int, input().split())
B = list(map(int, input().split()))
C = [0] + list(itertools.accumulate([(x + 1) / 2 for x in B]))
D = max((C[i] - C[i - K] for i in range(K, N + 1)))
print(D)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
expected = [0] * N
for i in range(N):
	expected[i] = (p[i] + 1) / 2
ans = 0
agg = 0
for i in range(N):
	if i < K:
		agg += expected[i]
	else:
		agg += expected[i]
		agg -= expected[i - K]
	ans = max(ans, agg)
print(ans)


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


(N, K) = [int(s) for s in input().split()]
P = [int(s) for s in input().split()]
E = list(map(lambda x: (x + 1) / 2, P))
E_SUMS = [E[0]]
for i in range(1, N):
	E_SUMS.append(E_SUMS[i - 1] + E[i])
m = E_SUMS[K - 1]
for i in range(K, N):
	m = max(m, E_SUMS[i] - E_SUMS[i - K])
print(m)


from itertools import *
(n, k, *p) = map(int, open(0).read().split())
q = [0] + list(accumulate([(x + 1) / 2 for x in p]))
print(max((q[i + k] - q[i] for i in range(n - k + 1))))


from itertools import accumulate
R = lambda : map(int, input().split())
(n, k) = R()
a = [0] + list(accumulate(R()))
print((max((y - x for (x, y) in zip(a, a[k:]))) + k) / 2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:k]) + k
t = s
for (a, b) in zip(p, p[k:]):
	t = t - a + b
	s = max(s, t)
print(s / 2)


def main():
	import numpy as np
	(N, K) = list(map(int, input().split()))
	P = np.array(input().split(), np.int32)
	P[:] += 1
	Pcum = np.zeros(N + 1, np.int32)
	Pcum[1:] = np.cumsum(P)
	length_K_sums = Pcum[K:] - Pcum[:-K]
	print(length_K_sums.max() / 2)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = [(x + 1) / 2 for x in p]
q1 = sum(q[:k])
ans = q1
for i in range(n - k):
	x = q1 - q[i] + q[i + k]
	q1 = x
	if ans < x:
		ans = x
print(ans)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
range_total = sum(P[:K]) + K
max_value = range_total
for i in range(N - K):
	range_total += P[K + i] - P[i]
	max_value = max(max_value, range_total)
print(max_value / 2)


def main():
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	ex = [0]
	for x in p:
		ex.append(ex[-1] + (x + 1) / 2)
	ans = 0
	for i in range(k, n + 1):
		ans = max(ans, ex[i] - ex[i - k])
	print(ans)
main()


(N, K) = (int(x) for x in input().split())
P = list(map(int, input().split()))
s = sum(P[0:K])
ans = [s]
for i in range(K, N):
	s = s + P[i] - P[i - K]
	ans.append(s)
S = max(ans)
print((S + K) / 2)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
num = 0
w = []
w = [1 + 0.5 * (i - 1) for i in s]
cnt = sum(w[:k])
ans = cnt
for i in range(n - k):
	cnt -= w[i]
	cnt += w[i + k]
	if cnt > ans:
		ans = cnt
print(ans)


(N, K) = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
a = sum(p[:K])
s = sum(p[:K])
for i in range(K, N):
	s += p[i] - p[i - K]
	a = max(a, s)
ans = (a + K) / 2
print(ans)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
num = [sum(p[0:k])]

def ap(num1):
	num.append(num1)
for i in range(n - k):
	ap(num[i] - p[i] + p[k + i])
print((max(num) + k) / 2)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
m = sum(s[0:k])
r = [m]
b = m
for i in range(n - k):
	b = b - s[i] + s[i + k]
	r.append(b)
r.sort()
print((r[-1] + k) / 2)


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
q = [0] * n
for i in range(n):
	q[i] = (1 + p[i]) / 2
s = [0] * (n + 1)
for j in range(n):
	s[j + 1] = s[j] + q[j]
t = k + 1
answer = s[k] - s[0]
while t <= n:
	answer = max(answer, s[t] - s[t - k])
	t += 1
print(answer)


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


(N, K) = map(int, input().split())
(*P,) = map(int, input().split())
Q = [p + 1 for p in P]
S = [sum(Q[:K])]
for (m, p) in zip(Q[:N - K], Q[K:]):
	S.append(S[-1] + p - m)
ans = max(S) / 2
print(ans)


(N, K) = map(int, input().split())
tu = tuple(map(int, input().split()))
l = [0] * (N + 1)
l[0] = 0
ans = 0
for i in range(1, N + 1):
	l[i] = l[i - 1] + (tu[i - 1] + 1) / 2
	if i >= K:
		ans = max(ans, l[i] - l[i - K])
print(ans)


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


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


(n, k) = map(int, input().split())
p = list(map(int, input().split()))
t = sum(p[:k])
max = t
for i in range(n - k):
	t += p[k + i] - p[i]
	if max < t:
		max = t
print((max + k) / 2)


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


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


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


raw = input().split(' ')
n = int(raw[0])
k = int(raw[1])
pref = []
raw = input().split(' ')
for i in range(n):
	elem = float(raw[i])
	if len(pref) == 0:
		pref.append((elem + 1) / 2)
	else:
		pref.append(pref[-1] + (elem + 1) / 2)
best = 0
idx = k - 1
while idx < n:
	if idx == k - 1:
		best = pref[idx]
	else:
		best = max(best, pref[idx] - pref[idx - k])
	idx += 1
print(best)


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


(N, K) = list(map(int, input().split()))
P = list(map(int, input().split()))
ans = [0]
ans[0] = sum(P[0:K])
for i in range(K, len(P)):
	ans.append(ans[-1] - P[i - K] + P[i])
print((max(ans) + K) * 0.5)


from numpy import *
(N, K) = map(int, input().split())
P = list(map(int, input().split()))
Q = (N - K + 1) * [0]
R = sum(P[0:K])
Q[0] = R
for n in range(1, N - K + 1):
	R += P[n - 1 + K] - P[n - 1]
	Q[n] = R
S = argmax(Q)
print(0.5 * (sum(P[S:S + K]) + K))


(n, k) = map(int, input().split())
p = [(x + 1) / 2 for x in map(int, input().split())]
o = sum(p[:k])
m = o
for i in range(n - k):
	o = o - p[i] + p[i + k]
	m = max(m, o)
print(m)


(N, K) = map(int, input().split())
P = list(map(int, input().split()))
tmp = sum(P[:K])
maxN = tmp
for i in range(1, N - K + 1):
	tmp = tmp - P[i - 1] + P[i + K - 1]
	if tmp >= maxN:
		maxN = tmp
print((maxN + K) / 2)


(N, K) = map(int, input().split())
p = list(map(int, input().split()))
for i in range(N):
	p[i] = p[i] / 2 + 0.5
s = 0
for i in range(K):
	s += p[i]
maxSum = s
j = 0
for i in range(K, N):
	s = s + p[i] - p[i - K]
	maxSum = max(maxSum, s)
print(maxSum)


from itertools import accumulate
(n, k) = map(int, input().split())
a = [0] + list(accumulate(map(int, input().split())))
print((max((a[i + k] - a[i] for i in range(n - k + 1))) + k) / 2)


from itertools import accumulate
(N, K) = map(int, input().split())
P = list(map(int, input().split()))
acc = [0] + list(accumulate(P))
print((max((b - a for (a, b) in zip(acc, acc[K:]))) + K) / 2)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = sum(l[:k])
kai = sum(l[:k])
for i in range(n - k):
	kai += l[i + k] - l[i]
	ans = max(ans, kai)
print((ans + k) * 0.5)


def f(x):
	x = int(x)
	return x * (x + 1) // 2 / x
(n, k) = list(map(int, input().split()))
p = list(map(f, input().split()))
s = sum(p[:k])
a = s
for i in range(k, len(p)):
	s += p[i] - p[i - k]
	a = max(a, s)
print(a)


(n, k) = map(int, input().split())
P = list(map(int, input().split()))
e = []
for i in P:
	e.append((i + 1) / 2)
cumsum = [0] * (n + 1)
for i in range(1, n + 1):
	cumsum[i] = cumsum[i - 1] + e[i - 1]
k_sum = cumsum.copy()
for i in range(n + 1):
	if i >= k:
		k_sum[i] -= cumsum[i - k]
print(max(k_sum[k - 1:]))


(n, k) = map(int, input().split())
P = list(map(int, input().split()))
P[0] = (P[0] + 1.0) / 2
for i in range(1, len(P)):
	P[i] = (P[i] + 1.0) / 2
	P[i] = P[i - 1] + P[i]
ans = 0.0
if n == 1:
	ans = P[0]
elif len(P) - k == 0:
	ans = P[k - 1]
else:
	for i in range(len(P) - k):
		ans = max(ans, P[i + k] - P[i])
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a[:k])
l = [s]
for x in range(n - k):
	s = s - a[x] + a[x + k]
	l.append(s)
print((max(l) + k) / 2)


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


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


(n, k) = map(int, input().split())
p = [int(i) + 1 for i in input().split()]
num = sum(p[:k])
ans = num
for i in range(n - k):
	tmp = p[i + k] - p[i]
	num += tmp
	if ans < num:
		ans = num
print(ans / 2)


(N, K) = map(int, input().split())
dice = list(map(int, input().split()))
a = sum(dice[0:K])
l = [a]
for i in range(1, N - K + 1):
	a = a - dice[i - 1] + dice[K - 1 + i]
	l.append(a)
print((max(l) + K) / 2)