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())
i = 0
kitaichi = [0] * n
kitaichi_sum = [0] * n
ans = 0
for p in input().split():
  kitaichi[i] = int(p) * (int(p)+1) / 2 / int(p)
  if i >= k-1:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
    if kitaichi_sum[i] > ans:
      ans = kitaichi_sum[i]
  elif i == 0:
    kitaichi_sum[i] = kitaichi[i]
  else:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i]
  if kitaichi_sum[i] > ans:
    ans = kitaichi_sum[i]
  i += 1
print(ans)

Submission status: Wrong Answer

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

max_list = []
max_value = 0

for v in range(N - K + 1):
  check_list = P[v:v+K]
  check = sum(check_list)
  if (max_value < check):
    max_value = check
    max_list = check_list

result = 0
print(max_list)
for i in max_list:
  i_re = 0
  for j in range(i + 1):
    i_re += j
  result += i_re / i

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

Submission status: Wrong Answer

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

max_e = 0

for i in range(K - 2):
    e = (p[i] + p[i + 1] + p[i + 2] + 3) / 2
    if e > max_e:
        max_e = e

print(max_e)

Submission status: Wrong Answer

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

max = []
for i in range(N-K+1):
    #print(i)
    target = P[i:i+K]
    #print(target)
    if sum(max) < sum(target):
        max = target

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

Submission status: Wrong Answer

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

# 初期化
pnmax = 0
for i in range(k):
  pnmax += ps[i]

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

print((pnmax+k)/2)

Submission status: Wrong Answer

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

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

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

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

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

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

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
i = 0
kitaichi = [0] * n
kitaichi_sum = [0] * n
ans = 0
for p in input().split():
  kitaichi[i] = int(p) * (int(p)+1) / 2 / int(p)
  if i >= k-1:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
    if kitaichi_sum[i] > ans:
      ans = kitaichi_sum[i]
  elif i == 0:
    kitaichi_sum[i] = kitaichi[i]
  else:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i]
  i += 1
print(ans)

Submission status: Wrong Answer

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

m, m_index, n = 0, 0, 0
for i in range(N-K+1):
    if P[i+K-1] > n and sum(P[i:i+K]) >= m:
        m = sum(P[i:i+K])
        m_index = i
        n = P[i]

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = map(int,input().split())
L = [int(x) for x in input().split()]
S = [0]
for x in range(N-K+1):
    NL = L[0+x:K+x]
    if sum(NL) > sum(S):
        S = NL
ANS = 0
for x in S:
    ANS += np.mean(range(1,x))
print(ANS)

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())
p=list(map(int, input().split()))
kitai=[0]*N
kitaiwa=[0]*(N-K+1)
if N==K:
    print(sum(kitai))
elif K==1:
    print(max(kitai))
else:
    for i in range(N):
        kitai[i]=(p[i]+1)/2
    for i in range(N-K+1):
        for j in range(K):
            kitaiwa[i]+=kitai[i+j]
    print(max(kitaiwa))

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])
#print(gokei)

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
max = 0
index = 0
res = 0

a = n - k + 1
b = k - 1

for i in range(a):
    for j in range(b):
        score.append(List[i+j])
    pre = sum(score)

    if max < pre:
        max = pre
        index = i
        pre = 0
    else:
        pre = 0
    score.clear()

for i in range(index, index+k):
    res += 1 + 0.5 * (List[i]-1)

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def ex(n):
    return (1+n)/2
def  ex3(p):
    return sum([(n+1)/2 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:
def calc(n):
  return (n+1)/2.0

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(calc,P))
print(Q)
cnt=0.0
for i in range(N-K+1):
  S=sum(Q[i:i+K])
  cnt=max(cnt,S)

print(cnt)

Submission status: Wrong Answer

Solution code:
def dice(num):
  return 0.5 * (num * (num + 1)) / num

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

pp = len(p)
sum = 0
ii = 0
for i in range(1, pp - k):
  temp = 0
  for kk in range(0, k):
  	temp += p[i+kk] 
  if temp > sum:
    ii = i

ans = 0.0
for kk in range(0, k):
  ans += dice(p[ii+kk])

print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
A = 0
for j in range(a[1]):
    A = A + b[j]
c = A
d = 0
ans = 0
if a[0] == a[1]:
    for l in range(a[0]):
        ans=ans + b[l] + 1
else:
    for i in range(a[1],a[0]):
        B = A - b[(i-a[1])] + b[i]
        if B > c:
            d = i - a[1] + 1
        A = B

    for k in range(a[1]):
        ans =ans + b[d+k] + 1
ans = ans / 2
print(ans)

Submission status: Wrong Answer

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

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
temp=0
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
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])
print(gokei)

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

Submission status: Wrong Answer

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

max_val = 0
max_idx = 0
tmp = 0
for i in range(1,N-K+2):
  if i == 1:
    tmp = sum(p[i-1:i-1+K])
  else:
    tmp = tmp - p[i-2] + p[i-2+K]
  if tmp > max_val:
    max_val = tmp
    max_idx = i

p = p[max_idx-1:max_idx-1+K]
p.sort()
prev_tmp = 0.0
expect = 0.0
for i in range(len(p)):
  tmp = 0.0
  if i == 0:
    for j in range(1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
  else:
    tmp = prev_tmp
    print(p[i-1]+1)
    for j in range(p[i-1]+1,p[i]+1):
      tmp += j
    expect += tmp/p[i]
    prev_tmp = tmp
print(expect)

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
ans = []

if d == 1:
  ans1 = max(a)
  print(ans1*0.5 + 0.5)
else:
  for i in range(n-d+1):
    left = a[i]
    right = a[i+d-1]

    if i == 0:
      Sum = sum(a[i:i+d])
      Max = 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 = list(map(int, input().split()))

exp_v = []
for dice in p:
    exp_v.append((dice+1)/2)

ans = 0
for k in range(1,N-K+1):
    ans = max(ans,sum(exp_v[k:k+K]))
print(ans)

Submission status: Wrong Answer

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

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

print((pnmax+k)/2)

Submission status: Wrong Answer

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

max_list = []
max_value = 0

for v in range(N - K + 1):
  check_list = P[v:v+K]
  check = sum(check_list)
  if (max_value < check):
    max_value = check
    max_list = check_list

result = 0
print(max_list)
for i in max_list:
  i_re = 0
  for j in range(i + 1):
    i_re += j
  result += i_re / i

print(result)

Submission status: Wrong Answer

Solution code:
n , k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
  a_i = (1+p[i])/2
def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += a_i
    return s
  
for i in range(n-k+1):
  r_i = sigma(i, i+k-1)
  
M = max(r_i for i in range(n-k+1))
print(M)

Submission status: Wrong Answer

Solution code:
num,a = map(int , input().split())
 
lis = list(map(int, input().split()))
 
dol = 0
cal = 0
cnum = 0
 
for p in range(a):  #0のとき
    dol += lis[p]

if a > 1:
    for i in range(1,num - a +1):
        cal = 0
        if lis[i-1] < lis[i+a-1]:
            for k in range(a):
                cal += lis[k+i]
            if dol < cal:
                dol = cal
                cnum = i
 
sum = 0

for p in range(a):
    sum += lis[p + cnum]
sum = sum/2 + 0.5*a

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

first_int = [int(k) for k in input().split()]
a = first_int[0]
b = first_int[1]
secound_list = [int(k) for k in input().split()]

def sigm(k):
  return np.sum(np.array(range(k+1)))/k

all_sigm = [sigm(k) for k in secound_list]
all_sigm_ = [sum(all_sigm[k:k+b+1]) for k in range(a)]
print(max(all_sigm_))

Submission status: Wrong Answer

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

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = ans - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]
  
ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P=input().split()
P = [int(p) for p in P]
maxv=0
expv=0

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

for i in range(N-K):
    expv=expv-P[i]+P[i+K]
    maxv=max(maxv,expv)
    
        
print("{:.20f}".format((maxv+K)/2))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split()) 
P = list(map(int,input().split()))
maxsize = 0
expectsum = 0
for i in range(N-K):
    if P[i]>P[i+K]:
        pass 
    else:
        sum_3 = sum(P[i+1:i+K+1])
        if sum_3 >= maxsize:
            max_size = sum_3
            expect = 0
            for j in range(K):
                expect += (P[i+1+j]+1)/2
                if expect > expectsum:
                    expectsum = expect
print(expectsum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list_ans = []

for i in range(n-k+1):
    list_sum = list_score[i:i+k]
    list_ans.append(sum(list_sum))

list_ans.sort()

print(list_ans)

print(list_ans[-1])

ans = list_ans[-1]*0.5 + 0.5*k

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    """"ここに今までのコード"""
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)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

prev = sum(p[1:k])
ind = 0

for i in range(1, n - k + 1):
    nex = prev - p[i - 1] + p[i + k - 1]

    if prev < nex:
        prev = nex
        ind = i

total = 0
for i in range(ind, ind + k):
    total += p[i] / 2 + 0.5

print(total)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P=input().split()
P = [int(p) for p in P]
maxv=0
expv=0

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

for i in range(N-K):
    expv=expv-P[i]+P[i+K]
    maxv=max(maxv,expv)
    
        
print("{:.12f}".format((maxv+K)/2))

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
i = 0
kitaichi = [0] * n
kitaichi_sum = [0] * n
for p in input().split():
  kitaichi[i] = int(p) * (int(p)+1) / 2 / int(p)
  if i >= k-1:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
  else:
    kitaichi_sum[i] = sum(kitaichi[0:i+1])
  i += 1
print(max(kitaichi_sum))

Submission status: Wrong Answer

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

c = N - K
dp = [0 for _ in range(c + 1)]

for i in range(c):
    if P[i] >= P[i + K]:
        dp[i + 1] = dp[i]
    else:
        dp[i + 1] = sum(
            map(lambda x: sum(range(1, int(x) + 1)) / x, P[i + 1:i + 1 + K]))

print('{:.10f}'.format(dp[c]))

Submission status: Wrong Answer

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

p.sort(reverse=True)

e = 0

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

print(e)

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)
val = val2
for i in range(k,n):
    if val < val2:
        val = val2
        atai = i-k+1
    #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())
A = list(map(int, input().split()))
B = sum(A[:K-1])
C =0
while C <= int(K):
    if sum(A[C:C+K]) > B:
      B = sum(A[C:C+K])
      C= C+1
    else:
      C = C+1
      continue
print((1/2)*(B+int(K)))

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])
#print(gokei)

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
s = list(map(float, input().split()))
t =[]
wa= 0
wa_max = 0

for i in range(0, N-K+1):
  wa = sum(s[i:i+K])
  if wa>wa_max:
    max_numbers = list(s[i:i+K])
    wa_max = wa

wa_kitai = 0

for v in max_numbers:
  wa_kitai += sum(list(range(int(v)+1)))/int(v)
print(max_numbers)

Submission status: Wrong Answer

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

answer = [0]*N
total = 0
for i in range(N):
    ev = sum(range(1,p[i]+1))/p[i]
    answer[i] = ev
    if i>K:
        total = max(total, sum(answer[i-K+1:i+1]))
print(total)

Submission status: Wrong Answer

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

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  
m = sum(dp[0:k])
max = m
for i in range(1,n-k + 1):
  m = m - p[i-1] + p[i+k-2]
  if m > max:
    max = m
print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

exps = []
ans = 0

for ii in range(N):  
  p[ii] = int(p[ii])
  e = np.arange(1,p[ii]+1)
  exps.append(np.sum(e)/p[ii])
  if ii - K >= 0:
    val = np.sum(exps[ii-K+1:ii+1])
    if val > ans:
      ans = val

print(ans)

Submission status: Wrong Answer

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

c = N - K
dp = [0 for _ in range(c + 1)]
dp[0] = sum(map(lambda x: sum(range(1, int(x) + 1)) / x, P[0: 0 + K]))

for i in range(c):
    if P[i] >= P[i + K]:
        dp[i + 1] = dp[i]
    else:
        dp[i + 1] = sum(
            map(lambda x: sum(range(1, int(x) + 1)) / x, P[i + 1:i + 1 + K]))

print('{:.10f}'.format(dp[c]))

Submission status: Wrong Answer

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

for i in range(N-K+1):
    m = sum(p[i:i+K])
    if m > max_l:
        max_l = m
        Max_l = p[i:i+K]


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

Submission status: Wrong Answer

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

prev = sum(p[1:k])
ind = 0

for i in range(1, n - k + 1):
    nex = prev - p[i-1] + p[i+k-1]

    if prev < nex:
        prev = nex
        ind = i

total = 0
for i in range(ind, ind + k):
    total += (p[i] * 0.5 + 0.5)

print(total)

Submission status: Wrong Answer

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

c=0
x=0
m=sum(p[0:k])
z=m
for i in range(1,n-k+1):
  z=z-p[i-1]+p[i+k-1]
  if m<z:
    x=i
#print(x)
for i in range(x,x+k):
  c+=((p[i]*(p[i]+1))/2)/p[i]
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sort()
sorted(reverse=true)

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

Decimal()
'''

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

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = [int(s) for s in stdin.readline().rstrip().split()]
past = -2000
for el in range(N - K + 1):
    if el == 0:
        past = 0
        continue
    if p[el - 1] < p[el + K - 1]:
        past = el
print(sum(list(map(lambda x: 1/2+x/2, p[past: past + K]))))

Submission status: Wrong Answer

Solution code:
def kitai(i):
    return sum(range(1,i+1))/i

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

p.sort(reverse=True)
ans=0.0
for j in p[0:k]:
    ans += kitai(j)
print(ans)

Submission status: Wrong Answer

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

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()))

an=0
an2=0
an3=0
flug=0
t=0

if k==1:
    print(int(max(p))*0.5+0.5)
    exit()

for i in range(n):
    if i<k:
        an+=p[i]
    else:
        t=p[i-k]
        if an+p[i]-t>an:
            an2=an+p[i]-t
            flug=(i-k)
        an=an+p[i]-t
            
print((an2*0.5)+(k*0.5))

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
p = [(int(i) + 1) * 0.5 for i in input().split()]
m = sum(p[:k])
for i in range(k, n):
    m = max(sum(p[i-k:i]), sum(p[i-k+1:i+1]))
print('{:.7f}'.format(m))

Submission status: Wrong Answer

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

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  

m = sum(dp[:k])
max = m
for i in range(1,n-k + 1):
  m = m - p[i-1] + p[i+k-1]
  if m > max:
    max = m
print(max)

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(ans)
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 = map(int, input().split())
p = input().split()
ex = [0 for i in range(N)]
E=0
S=0
def expectation(n):
    return (n+1)/2


for i in range(N):
    p[i] = int(p[i])
    ex[i] = expectation(p[i])

X = N-K+1
for i in range(X):
    newS = 0
    k =0
    for j in range(K):
        newS += p[i+j] 
        

    if newS > S:
        S = newS
        k=i

for j in range(K):
    E += ex[k+j]

print(E)

Submission status: Wrong Answer

Solution code:
import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = list(itertools.accumulate(A))

    ans = 0
    for i in range(M, N):
        ans = max(ans, l[i] - l[i-M])
    ans = (ans+M) / 2
    
    return ans

print(solve())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

prev = sum(p[1:k])
ind = 0

for i in range(2, n - k + 1):
    nex = prev - p[i-1] + p[i+k-1]

    if prev < nex:
        prev = nex
        ind = i

total = 0
for i in range(ind, ind + k):
    total += (p[i] * 0.5 + 0.5)

print(total)

Submission status: Wrong Answer

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

def calc(n):
    return sum([i for i in range(1, n+1)]) / n
p.sort()
m = sum([calc(i) for i in p[-K:]])
print(m)

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
np.array(B)
C = (B+np.array([1]))/np.array([2])
print(sum(C))

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 = s

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

    if s_max < s:
        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()))

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  

m = sum(dp[:k])
max = m
for i in range(1,n-k + 1):
  m = m - p[i-1] + p[i+k-1]
  if m > max:
    max = sum(dp[i:i+k])
print(max)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
A = 0
for j in range(a[1]):
    A = A + b[j]
c = A
d = 0
for i in range(a[1],a[0]):
    B = A - b[(i-a[1])] + b[i]
    if B > c:
        d = i - a[1] + 1
    A = B
ans = 0
for k in range(a[1]):
    ans =ans + b[d+k] + 1
ans = ans/2
print(ans)

Submission status: Wrong Answer

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

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

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

num = sum(num_li[:k])


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

print(ans)

Submission status: Wrong Answer

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

S, T = list(map(int,(input().split())))
p = list(map(int,(input().split())))
ans = 0
anss = []
temp_sum= 0
sum_max = []
for i in range(T):
  ans = 0
  samp = p[i:T+i]
  if temp_sum < sum(samp):
    temp_sum = sum(samp)
    sum_max.append(samp)
    
#print(sum_max)
for i in sum_max[-1]:
  x =(list(range(1,i+1)))
  ans += sum(x)/len(x)
  
print(ans)

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 += a[i]
print(ans)

Submission status: Wrong Answer

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

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  

m = sum(dp[:k])
max = m
for i in range(1,n-k + 1):
  m = m - p[i] + p[i+k-1]
  if m > max:
    max = sum(dp[i:i+k])
print(max)

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):
    if val < val2:
        val = val2
        atai = i-k+1
    #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 = [int(i) for i in input().split()]
list.sort(p)
print((sum(p[n-k:n])+k)/2)

Submission status: Wrong Answer

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

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = ans - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]
  
ans, num = 0, 0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
P=input().split()
P = [int(p) for p in P]
maxv=0
expv=0

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

for i in range(N-K):
    expv=expv-P[i]+P[i+K]
    maxv=max(maxv,expv)
    
        
print((maxv+K)/2)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
A = 0
for j in range(a[1]):
    A = A + b[j]
c = A
d = 0
for i in range(a[1],a[0]):
    B = A - b[(i-a[1])] + b[i]
    if B > c:
        d = i - a[1] + 1
    A = B
ans = 0

print(d)
for k in range(a[1]):
    ans =ans + b[d+k] + 1
ans = ans/2
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])
    s = np.sum(ar, axis=0)
    print(max(s))

Submission status: Wrong Answer

Solution code:
num,a = map(int , input().split())
 
lis = list(map(int, input().split()))
 
dol = 0
cal = 0
cnum = 0
 
for p in range(a):  #0のとき
    dol += lis[p]

if a > 1:
    for i in range(1,num - a +1):
        cal = 0
        if lis[i-1] < lis[i+a-1]:
            for k in range(a):
                cal += lis[k+i]
            if dol < cal:
                dol = cal
                cnum = i
 
sum = 0
for p in range(a):
    sum += lis[p + cnum] * (lis[p + cnum] + 1) / (2 * (lis[p + cnum]))
 
print(sum)

Submission status: Wrong Answer

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


maxnum=0
index=0
num=0
for i in range(len(P)-K+1):
    num+=P[i]



    if maxnum<num:
        maxnum=num
        index=i



    if i>=K-1:
        num-=P[i-(K-1)]

List=[]
for i in range(K):
    x1=P[index+i]
    sumx1=0
    for j in range(1,x1+1):
        sumx1+=j

    sumx1=sumx1/x1
    List.append(sumx1)


print(sum(List))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = sum(A[:K-1])
C =1
while C <= int(K):
    if sum(A[C:C+K]) > B:
      B = sum(A[C:C+K])
      C= C+1
    else:
      C = C+1
      continue
print((1/2)*(B+int(K)))

Submission status: Wrong Answer

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

ans = (sum(P[:K]) + K) / 2
for i in range(1, N - K):
    if P[i - 1] <= P[i + K - 1]:
        res = (sum(P[i: i + K]) + K) / 2
        if res < ans:
            continue
        else:
            ans = res
    else:
        continue
print(ans)