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

for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += a[i + j]
    if d > max_d:
        max_i = i
        max_d = d
ans = 0
for i in range(max_i,max_i + k):
    ans += i
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

    def calc(p):
        if p % 2 == 0:
            return p/2 + 0.5
        else:
            return math.ceil(p/2)

    E = [calc(pi) for pi in P]
    #print(E)

    best_idx = 0
    best_sum = 0

    cs = np.cumsum(E)

    for i in range(K-1, N-1):
        #print(i)
        s = cs[i+1] - cs[i-K+1]
        if s > best_sum:
            best_sum = s
            best_idx = i

    print(best_sum)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

for i in range(len(p)):
    p[i]=(p[i]+1)/2
tmp=0
x=sum(p[0:k])
for i in range(k,len(p)):
    x=x-p[i-k]+p[i]
    if x>tmp:
        tmp=x
print(tmp)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
index = 0
value = 0

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

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

print(value)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_bef = list(map(int, input().split()))
p_aft = sorted(p_bef, reverse = True)
ans = 0
for i in range(k):
   ans += (1 + p_aft[i]) / 2
print(ans)

Submission status: Wrong Answer

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

saidai = 0
gokei = sum(p[0:K])

for i in range(N-K+1):
	if i+K+1 < N:
		gokei = gokei - p[i] + p[i+K+1]
		if saidai < gokei:
				saidai = gokei

print((saidai+K)/2)

Submission status: Wrong Answer

Solution code:
n ,k = map(int,input().split())
a = list(map(int,input().split()))
max_i = 0
max_d = 0

for i in range(n - k + 1):
    d = 0
    for j in range(k):
        d += a[i + j]
    if d > max_d:
        max_i = i
        max_d = d
ans = 0
for i in range(max_i,max_i):
    ans += i
print(ans)

Submission status: Wrong Answer

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

ans_max = 0
max_num = 0
max_index = 0

for i in range(n):
    if(max_num < p[i]):
        max_num = p[i]
        max_index = i

first_index = max_index - k + 1
if(first_index < 0):
    first_index = 0

last_index = max_index
if(max_index > n - k):
    last_index = n - k + 1

if(first_index == last_index):
    first_index -= 1

for i in range(first_index, last_index):
    temp = 0
    for j in range(k):
        temp += (p[i + j] * (p[i + j] + 1) / 2) / p[i + j]

    if(ans_max < temp):
        ans_max = temp

print(ans_max)

Submission status: Wrong Answer

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

l = [0]
for i in range(n-k+1):
    if l < p[i:i+k]:
        l = p[i:i+k]

l = list(map(lambda x: x * (x+1) * 1/2 * 1/x, l))

print(sum(l))

Submission status: Wrong Answer

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

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

for i in range(NK[1], NK[0]):
    if (P[i] > P[i - NK[1]]):
        sum = 0
        for j in range(NK[1]):
            sum += P[i - j]
            if (P[i - j] != 1):
                sum += 1


print(sum / 2)

Submission status: Wrong Answer

Solution code:
a = input().split()
b = input().split()

ans = 0
be = 0

for i in range(int(a[0])-int(a[1])+1):
    sum = 0
    be = int(b[i])
    if be < int(b[i+int(a[1])-1]):
        for j in range(int(a[1])):
            sum += (1 + int(b[i+j]))/2
        if ans < sum:
            ans = sum

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

if K == 1:
    print((max(Ps)+1)/2)
else:
    max_val = 0
    d = deque(maxlen=K)
    for i, n in enumerate(Ps):
        if i < K:
            d.append(n)
            continue
        popleft_val = d.popleft()
        d.append(n)
        if popleft_val >= n:
            continue
        val = sum(d)
        if max_val < val:
            max_val = val
    print((max_val + K) / 2)

Submission status: Wrong Answer

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

max1 = 0
idx = 0
tmp = 0
for j in range(n):
    if len(d[j:j+k]) < k:
        break
    else:
        if j == 0:
            tmp = sum(d[j:j+k])
        else:
            tmp = tmp - d[j-1] + d[j+k-1]
    if max1 < tmp:
        idx = j
        max1 = tmp
sum1 = 0.0
s = 0
old = 0
oldsum = 0.0
for i in d:
    dice = list(range(1+old,i+1))
    if len(dice) != 0:
        s = sum(dice) + oldsum
        ex = s / i
        sum1 += ex
        old = i
        oldsum = s
    else:
        sum1 += ex

print(sum1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int,input().split())
P = list(map(int,input().split()))
total = 0
for i in range(N-K+1):
  A = P[i:i+K]
  total = sum(A)
  if total>0:
    B = A
print(B)
np.array(B)
C = (B+np.array([1]))/np.array([2])
print(sum(C))

Submission status: Wrong Answer

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

number_list = []

sum_max = 0
tmp_max = 0
past_max = 0
tmp_max_list = []
for index, p in enumerate(p_list):
    if index >= K:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max -= tmp_max_list[index - K]
        if sum_max < tmp_max:
            sum_max = tmp_max
        tmp_max_list.append((p * (p + 1)) / 2 / p)
    else:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max_list.append((p * (p + 1)) / 2 / p)

if N == 1:
    print('{:.12f}'.format(float(p_list[0] * (p_list[0] + 1) / 2 / p_list[0])))
else:
    print('{:.12f}'.format(float(sum_max)))

Submission status: Wrong Answer

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

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])
dp=[0 for _ in range(N)]
mi=0
dp[0]=sum(p[0:K])
for i in range(N-K):
    if p[i]<p[i+K]:
        dp[i+1]=dp[i]+p[i+K]-p[i]
        mi=i+1
    else:
        dp[i+1]=dp[i]
print(ex3(p[mi:mi+K]))

Submission status: Wrong Answer

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

saidai = 0
base = sum(p[0:K])

for i in range(N-K+1):
	if i+K+1 < N:
		gokei = 0
		gokei = base - p[i] + p[i+K+1]
		if saidai < gokei:
				saidai = gokei

print((saidai+K)/2)

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, input().split()))

if (K > N/2):
    ans = 0
    for i in range(N-K+1):
        a = sum(P[i:i+K])
        ans = a if a > ans else ans
    print(P)
else:
    ar = []
    for i in range(K):
        ar.append(P[i:i+K])
    s = np.sum(ar, axis=0)
    print(max(s))

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]
#print(ln_mean)

lnk = [0]*k
for i in range(k):
  tmp_lnk = ln_mean[i:i+k]
  lnk[i] = sum(tmp_lnk)

print(max(lnk))

Submission status: Wrong Answer

Solution code:
def DE(n):
    return float((n+1)*(n/2)/n)

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    ls = p[:K]
    ans = sum(list(map(DE,ls)))
    for i in range(K,N):
        tmp = ans - DE(p[i-K]) + DE(p[i])
        if tmp >= ans:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b = input().split()
arr = list(map(int,input().split()))
ans = 0

for i in range(0, int(a) - int(b) + 1):
    c = 0
    for j in range(i,i + int(b)):
        print(arr[j])
        c += (1 + arr[j])
    if ans < c / 2:
        ans = c / 2



print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int, input().split())
p = np.array(list(map(int,input().split())))
p = (p+1)/2
sorted_p = np.sort(p)[::-1]
ans = sum(sorted_p[0:K])
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, input().split()))

if True:
    # if (K > N/2):
    #     ans = 0
    #     for i in range(N-K+1):
    #         a = sum(P[i:i+K])
    #         ans = a if a > ans else ans
    #     print(P)
    # else:
    ar = []
    for i in range(K):
        ar.append(P[i:i+K])
    print(ar)
    s = np.sum(ar, axis=0)
    print(s)
    print(max(s))

Submission status: Wrong Answer

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

P = sorted(P, reverse=True)

dice_list = P[0:K]

A = []
for i in dice_list:
    for j in range(1, i+1):
        A.append(j/i)
    

print(sum(A))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

N, K = map(int, input().split())
p = list(map(int, input().split()))
# print(N, K)
# print(p)
p_sorted = sorted(p, reverse=True)

def e_dice(n):
    res = 0
    for i in range(1, n+1):
        res += i * (1 / n)
    return res

res = 0
for i in range(K):
    res += e_dice(p_sorted[i])

print(res)

Submission status: Wrong Answer

Solution code:
def mysum(n):
    ans = 0
    for i in range(n + 1): 
        ans += i  
    return ans

n,k = map(int,input().split())
p = list(map(int,input().split()))
a2=[0]
Max = 0
for i in p:a2.append(a2[-1]+i)
lists = []
for i in range(n-k+1):
    lists.append(a2[i+k] - a2[i])
jud = max(lists)
for i in range(len(lists)):
    if lists[i] == jud:
        tmp = i
ans = p[tmp:tmp+k]
set_ans = set(ans)
cnt = 0
for i in set_ans:
    cnt += mysum(i) / i
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n,k=map(int,input().split())
p=[ int(i) for i in input().split() ]
p_list=[]
wa=0

for j in range(len(p)-2):
    P_list=p[j:j+k]
    if sum(p_list) < sum(P_list):
        p_list = P_list

for k in p_list:
    wa += ((1+k)*k/2) / k

print(wa)

Submission status: Wrong Answer

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

n, k = [int(i) for i in input().split()]
p = [0] * n
for i,v in enumerate(input().split()):
    p[i] = 1.0 + 0.5 * (float(v) - 1.0)

_max_sum = 0
_prev_sum = sum(p[:k])
for i in range(1, n-k+1):
    _sum = _prev_sum - p[i-1] + p[i+k-1]
    if _sum >= _max_sum:
        _max_sum = _sum
    _prev_sum = _sum
print(_max_sum)

Submission status: Wrong Answer

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

N,K=map(int,input().split())
p=list(map(int,input().split()))
t=0
k=sum(p[0:K])

for i in range(N-K):
  k-=p[i]
  k+=p[i+K]
  if k>t:
    t=k
    
print((K+t)/2)

Submission status: Wrong Answer

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

dices =[]
dicesSum=[]
for i in range(N-K+1):
    l= ps[i:i+K]
    dices.append(l)
    dicesSum.append(sum(l))


max_value = max(dicesSum)
max_index = dicesSum.index(max_value)


print(dices[max_index])


total = sum(dices[max_index])
exp = (total+len(dices[max_index]))/2
print(exp)

Submission status: Wrong Answer

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

ans = 0
tmp,ind,sumn = sum(p[0:k]),0,sum(p[0:k])
#print(tmp)
"""
for i in range(len(p)-k+1):
    if sum(p[i:i+k]) >= sumn:
        ind,sumn = i,sum(p[i:i+k])
"""
for i in range(len(p)-k+1):
    tmp += p[i+k-1]-p[i]
    if tmp >= sumn:
        ind,sumn = i,tmp


for i in p[ind:ind+k]:
    ans += (i+1)/2
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def DE(n):
    return (n+1)*(n/2)/n

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    ls = p[:K]
    ans = sum(list(map(DE,ls)))
    for i in range(K,N):
        tmp = ans - DE(p[i-K]) + DE(p[i])
        if tmp >= ans:
            ans = tmp
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


kitaiti = {}

k = 1.0
for i in range(1, 1001):
    kitaiti[i] = k
    k += 0.5

array = P[0:K]
index = 0

for i in range(K):
    index += kitaiti[P[i]]

ans = index

for i in range(1, len(P)-K+1):
    s = index - kitaiti[P[i-1]] + kitaiti[P[i+K-1]]
    if s > index: ans = s
    index = s
print(ans)

Submission status: Wrong Answer

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

A = 0
for i in range(n-k):
  y = 0
  for j in p[i:i+k]:
    if j == 1:
      x = 1
    else:
      x = ((j-1)/2) + 1
    y += x
  if A < y:
    A = y

print(A)

Submission status: Wrong Answer

Solution code:
N, K = input().strip().split(' ')
p = input().strip().split(' ')
buf = 0
for r in range(int(K)):
  a = int(p[(-1 - r)])
  for i in range(a):
    buf = buf + (1 / a) * (i + 1)
print(buf)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = []
for i in range(N):
    e = (p[i] * (p[i] + 1)) / 2 / p[i]
    queue.append(e)
    if K <= i:
        tmp_ans = tmp_ans - queue[0] + e
        if queue[0] < e:    
            max_ans = tmp_ans
        queue.pop(0)
    else:
        tmp_ans += e
        max_ans = tmp_ans

print(max_ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
L=sorted(list(p[i:K+i] for i in range(N-K+1)))
num=sum((_+1)/2 for _ in L[-1])
print(num)

Submission status: Wrong Answer

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

ans = 0
temp_max = 0
p_sum = 0


def kitai(p_num):
    if p_num % 2 == 0:
        p_sum = (1 + p_num)*(p_num/2)
    else:
        p_sum = (1 + p_num)*(p_num//2) + -(-p_num//2)

    return p_sum / p_num


kitai_p = list(map(kitai, p))

for i in range(k):
    temp_max += kitai_p[i]

current = temp_max
for i in range(len(kitai_p) - k):
    current = current - kitai_p[i] + kitai_p[k+i]

    if ans < current:
        ans = current

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import *
from heapq import *
from fractions import gcd
import itertools
import math
import numpy as np

sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()

N, K = InMap()
P = np.array(InMap(),dtype=np.float64)
P += 1
P /= 2
v = np.ones(K)
Res = np.convolve(P, v)
# Res = [sum(E[i:i+K]) for i in range(N-K+1)]

Submission status: Wrong Answer

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

kitaiti = [0 for _ in range(n)]
ruisekiwa = [0 for _ in range(n)]
r = k - 1
max = 0

for i in range(n):
    kitaiti[i] = (p[i]+1) / 2
    if i == 0:
        ruisekiwa[0] = kitaiti[0]
    else:
        ruisekiwa[i] = ruisekiwa[i-1] + kitaiti[i]
    if i == r:
        now = ruisekiwa[i]
    elif i > r:
        now = ruisekiwa[i] - ruisekiwa[i-r-1]
        if now > max:
            max = now
print(max)

Submission status: Wrong Answer

Solution code:
def DE(n):
    return (n+1)*(n/2)/n

def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    ls = p[:K]
    ans = sum(ls)
    index = 0
    for i in range(K,N):
        tmp = ans - p[i-K] + p[i]
        if tmp >= ans:
            ans = tmp
            index = i
    ls = p[index-K+1:index+1]
    print(sum(list(map(DE,ls))))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, K = mulinputs()
ps = list(mulinputs())
# memo = dict()
# def kitaiti(s):
#     if s in memo.keys():
#         return memo[s]
#     n = int(s)
#     k = ((n*(1+n))>>1)/int(n)
#     memo[s] = k
#     return k
# ps = list(map(kitaiti, input().split()))

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

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

# 出力
print(cnt)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
val2 = 0
for i in range(k):
    val2 += p[i]
#print(val2)
for i in range(k,n):
    #print(i,p[i],p[i-k])
    val2 += p[i]
    val2 -= p[i-k-1]
    #print(val2)
    if val < val2:
        val = val2
        atai = i-k+1

#print(atai)
ans = 0
for i in range(k):
    kitai = 0
    for j in range(1,p[atai]+1):
        kitai += j
    ans += kitai / p[atai]
    atai += 1
    #print(atai)
    #print(kitai)
print(ans)

Submission status: Wrong Answer

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


kitaiti = {}

k = 1.0
for i in range(1, 1001):
    kitaiti[i] = k
    k += 0.5

array = P[0:K]
index = 0
ans = 0

for i in range(K):
    index += kitaiti[P[i]]

for i in range(1, len(P)-K+1):
    s = index - kitaiti[P[i-1]] + kitaiti[P[i+K-1]]
    if s >= index: ans = s
    index = s
print(ans)

Submission status: Wrong Answer

Solution code:
import decimal

n, k = map(int, input().split())
p_list = list(map(int, input().split()))
index = 0
value = 0

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

for i in range(k):
    for j in range(p_list[index + i]):
        value += decimal.Decimal(j + 1) / decimal.Decimal(p_list[index + i])

print(value)

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
c=list(map(int, input().split()))
kitaichi = []
for i,v in enumerate(c):
    kitaichi.append((v/2*(v+1))/v)

score = []
for i,v in enumerate(kitaichi):
    if i+2 == len(kitaichi): break
    score.append(sum(kitaichi[i:i+3]))
print(max(score))

Submission status: Wrong Answer

Solution code:

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

E = []
for p in P:
    e = 0
    for i in range(1,p+1):
        e += i/p
    E.append(e)



print(E)
ANS = s = sum(E[0:K])


for i in range(1,N-K+1):
    #sum(E[i:i+K])
    s = s+E[i+K-1]-E[i-1]
    print(ANS, s)
    ANS = max(ANS, s)


print(ANS)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k = list(map(int,input().split()))
p = np.array(list(map(int,input().split())))

P = 0
for i in range(n-k+1):
  if P < p[i:i+k].sum():
    P = p[i:i+k].sum()
    mp = p[i:i+k]

ans = 0
print(mp)
for i in mp:
  if i%2 == 0:
    ans += ((i+1) * i//2)/i
  else:
    ans += ((i+1) * (i//2) + (i//2) + 1)/i
print(ans)

Submission status: Wrong Answer

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

rp = sum(list(p[0:K]))
rm = 0
ans = rp
for i in range(N-K):
  if rp - rm > ans:
    ans = rp - rm
  rp += p[i+K]
  rm += p[i]

print((ans+K)/2)

Submission status: Wrong Answer

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

l = 0
r = k
ansl = 0
ansr = 0
ans = 0
tmp = sum(p[:k])
# print(tmp)
for i in range(1,n - k+1):
    tmp = tmp - p[i-1] + p[i + k-1]
    # print(i,i+k-1,tmp)
    if tmp > ans:
        ansl = i
        ansr = i + k - 1
        ans = tmp
# print(ansl, ansr)
ans2 = 0
for i in range(ansl, ansr + 1):
    ans2 += (p[i] + 1) / 2
print(ans2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
  
ans = []
n = p.index(max(p))
for i in range(K):
  if n - i >= 0 and n - i + K <= len(p):
    a = p[n - i : n - i + K]
    if sum(a) > sum(ans):
      ans = a

print((sum(ans) + K) /2)

Submission status: Wrong Answer

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

ans_max = 0
max_num = 0
max_index = 0

for i in range(n):
    if(max_num < p[i]):
        max_num = p[i]
        max_index = i

last_index = max_index
if(max_index > n - k):
    last_index = n - k + 1

first_index = max_index - k + 1
if(first_index < 0):
    first_index = 0

for i in range(first_index, last_index):
    temp = 0
    for j in range(k):
        temp += (p[i + j] * (p[i + j] + 1) / 2) / p[i + j]

    if(ans_max < temp):
        ans_max = temp

print(ans_max)

Submission status: Wrong Answer

Solution code:
nk = list(map(int, input().split()))
N = nk[0]
K = nk[1]
p = list(map(int, input().split()))



def max_cal(max_p,sum_p):
    if(max_p < sum_p):
        max_p = sum_p
    return max_p

if __name__ == '__main__':
    max_p = 0
    sum_p = 0
    for k in range(K):
        sum_p = sum_p + p[k]
    #print(sum_p)
    for j in range(1,N-K+1):
        sum_p = sum_p - p[j-1] + p[j+K-1]
        max_p = max_cal(max_p, sum_p)
    #print(max_p)
    print((max_p+K)/2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
a = {1: 1}
for i in range(2, 10001):
  a[i] = a[i - 1] + i
for i in range(2, 10001):
  a[i] /= i
b = [0] * N
for i in range(N):
  b[i] = a[P[i]]
m = 0
for i in range(K):
  m += b[i]
ans = 0
for i in range(K, N):
  m = m + b[i] - b[i - K]
  ans = max(ans, m)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# 最初のpnmaxの計算
pnmax = 0
for i in range(k):
  pnmax += ps[i]

for i in range(n-k):
  if(ps[k+i] > ps[i]):
    pnmax = pnmax - ps[i] + ps[k+i]

print((pnmax+k)/2)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
P=list(map(int,input().split()))
p=np.cumsum(P)
s=[0]*(n//k+1)
MAX=p[0]
res=[]
ans=0
for i in range(0,n-k):
    MAX=max(MAX,p[i+k]-p[i])
    if MAX==p[i+k]-p[i]:
        res=P[i+1:i+k+1]
for j in res:
    ans+=np.cumsum(range(1,j+1))[-1]/j
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans_temp = 0
ans_list = []
for i in range(n):
    try:
        if ans_temp < sum(p[i:i+k]):
            ans_temp = sum(p[i:i+k])
            ans_list = p[i:i+k]
    except:
        pass
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:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

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

#重複を検出
def has_duplicates(seq):
  return len(seq) != len(set(seq))



#X = str(input()).split()
#a = [int(x) for x in input().split()]


NK = str(input()).split()
N = int(NK[0])
K = int(NK[1])
p = [int(x) for x in input().split()]

M = 0
ans = 0

for i in range(K):
  M+= p[i]

ans = M
ans2 = 0
ans3 = 0
ans4 = 0

for i in range(K, N):
  if(ans < ans-p[i-K]+p[i]):
    ans2 = i-K+1
    ans = ans-p[i-K]+p[i]

for i in range(ans2,ans2+K):
  for j in range(p[i]+1):
    ans3 += j
  ans4 += float(ans3/p[i])
  ans3 = 0


print(ans4)

Submission status: Wrong Answer

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

kitaiti = [0 for _ in range(n)]
ruisekiwa = [0 for _ in range(n)]
l = 0
r = k - 1
max = 0

for i in range(n):
    kitaiti[i] = (p[i]+1) / 2
    if i == 0:
        ruisekiwa[0] = kitaiti[0]
    else:
        ruisekiwa[i] = ruisekiwa[i-1] + kitaiti[i]
    if i > r:
        now = ruisekiwa[i] - ruisekiwa[i-r-1]
        if now > max:
            max = now
print(max)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p_=input().split()
p=[]
for i in p_:
    p.append(int(i))
p.sort()
result=0
for i in range(k):
    result+=p[-i]/2
print(result)

Submission status: Wrong Answer

Solution code:
import numpy

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

res = numpy.cumsum(q)

ans = []
ans.append(q[k-1])
for i in range(k,n):
  ans.append(res[i]-res[i-k])
print(max(ans))

Submission status: Wrong Answer

Solution code:
'''
def expect(p):
    ans = (p+1)/2
    ans = sums[p-1]/p
    return ans
'''

# n = int(input())
# s = input()
n, k = map(int, input().split())
p = list(map(int, input().split()))
# a = input().split()
'''
sums = [1]*max(p)
for i in range(1, max(p)+1):
    sums[i] = sums[i-1] + i+1

exP = []
for idp in p:
    ex = expect(idp)
    exP.append(ex)

ans = 0
for j in range(n-k):
    tmp = sum(exP[j:j+k])
    ans = max(ans, tmp)
'''
ans = 0
for j in range(n-k):
    tmp = sum(p[j:j+k])
    ans = max(ans, tmp)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0
Sum = 0

for i in range(n-d+1):
  left = a[i]
  right = a[i+d-1]
  
  if i == 0:
    Sum = sum(a[i:i+d])
  else:
    Sum = Sum + right - left
    
  if Sum >= Max:
    Max = Sum
    ans = a[i:i+d]    
  else:
    pass

ans = np.array(ans)
ans = ans*0.5 + 0.5
print(sum(ans))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p_i = list(map(int,input().split()))
answer = 0
sum = 0
for x in range(n - k + 1):
    if x <= k - 1: 
        sum += p_i[x]
        if x == k - 1: answer = sum
    else:
        sum += p_i[x] - p_i[x - k]
        answer = max(answer, sum)
print((answer + k) / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
NK = [int(i) for i in input().split(" ")]
list1 = [(int(i)+1)/2 for i in input().split(" ")]
Max = 0
for j in range(NK[0]-NK[1]+1):
    if Max<sum(list1[j:j+NK[1]]):
        Max=sum(list1[j:j+NK[1]])

Submission status: Wrong Answer

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

saidai = 0

for i in range(N-2):
	gokei = 0
	for j in range(K):
		if i+j < N:
			#print(p[i+j])
			gokei += (p[i+j] + 1)/2
	if saidai < gokei:
			saidai = gokei

print(saidai)

Submission status: Wrong Answer

Solution code:
import itertools

n, k = map(int, input().split(" "))
p_list = list(map(int, input().split(" ")))
max_num = 0
ans = 0

m = p_list.index(max(p_list))

for i in range(m-k,m+k,1):
    sum_list = sum(p_list[i:i+k])
    if max_num < sum_list:
        max_num = sum_list
        ans_list = p_list[i:i+k]


"""
for i in range(n-(k-1)):
    sum_list = sum(p_list[i:i+k])
    if max_num < sum_list:
        max_num = sum_list
        ans_list = p_list[i:i+k]
"""

for i in range(k):
    ans = ans + sum(range(ans_list[i]+1))/ans_list[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
p = 0
q = 0
ma = 0
for i in range(1,N-K):
  for j in range(K):
    q += P[j+i]
    if ma < q:
      p = i
      ma = q
#print(p)
s = 0
for i in range(p, p+K):
  for j in range(1, 1+P[i]):
    s += (j)*(1/P[i])
print(s)

Submission status: Wrong Answer

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

def exp(n):
    if n % 2 == 0:
        s = (n+1)*n/2
    else:
        s = (n+1)*(n-1)/2+(n+1)/2
    ans = s / n
    return ans

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

M = 0
for i in range(N-K+1):
    S = float(0)
    for j in range(K):
        S += exp(p[i+j]) 
    print(S)       
    if M < S:
        M = S

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