Problem:


Score : 400 points

Problem Statement

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

1 ≤ K ≤ N ≤ 200000

1 ≤ p_i ≤ 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is 3.5.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000



Sample input:
5 3
1 2 2 4 5


Sample output:
7.000000000000

Submission status: Wrong Answer

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

#n面サイコロの出る目の期待値
def n_mean(n):
  return 0.5*(n+1)

Pmean=list(map(lambda x: n_mean(x), P))
Psum=[0]*N
Psum[0]=Pmean[0]
for i in range(1,N):
  Psum[i]=Psum[i-1]+Pmean[i]
print(Psum)
ans=0
for i in range(N-K+1):
  if i==0:
    ans=Psum[K-1]
  else:
    #1~6 
    ans=max(ans, (Psum[i+K-1]-Psum[i-1]))
  
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate    # 累積和: list(accumulate(num_list))

def main():
    n, k = map(int, input().split())
    num_list = list(map(int, input().split()))

    compute_list = []

    for num in num_list:
        compute_list.append((1+num)/2)

    sum_list = list(accumulate(compute_list))

    ans = 0

    if k == n:
        ans += sum(sum_list)
        print(ans)
        exit()

    for i in range(n-k):
        ans = max(ans, sum_list[i+k] - sum_list[i])

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import accumulate    # 累積和: list(accumulate(num_list))

def main():
    n, k = map(int, input().split())
    num_list = list(map(int, input().split()))

    compute_list = []

    for num in num_list:
        compute_list.append((1+num)/2)

    sum_list = list(accumulate(compute_list))

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def __main():
    n,k = map(int, input().split())
    P = list(map(int, input().split()))
    P = list(map(lambda x:(x+1)/2, P))

    cur = sum(P[:k])
    #print('first ', cur)
    ans = 0

    for i in range(1, n-k+1):
        cur += P[i+k-1] - P[i-1]
        if cur < ans: continue
        ans = cur

    print(ans)
__main()

Submission status: Wrong Answer

Solution code:
import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
m = (np.array(p) + 1)/2
cum  = np.cumsum(m)

ma = 0
for i in range(n - k):
    a = cum[i + k] - cum[i]
    if ma < a:
        ma = a
print(ma)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l2 = [0 for _ in range(k)]
for i in range(n-k+1):
  if s < sum(l[i:i+k]):
    s = sum(l[i:i+k])
    for j in range(k):
      l2[j] = i + j
ans = 0
for i in range(k):
  ans += (1+l[l2[i]])/2
  ans=1.1234567
print("{:.8}".format(ans))

Submission status: Wrong Answer

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

# pp_ex = list(map(lambda p: (p * (p + 1) / 2) / p, pp))

max_ex = 0
for i in range(n - k + 1):
    ex = 0
    for j in range(k):
        ex += pp[i + j]
    if max_ex < ex:
        max_ex = ex

print(max_ex)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l2 = [0 for _ in range(k)]
for i in range(n-k):
  if s < sum(l[i:i+k]):
    s = sum(l[i:i+k])
    for j in range(k):
      l2[j] = i + j
      
ans = 0
for i in range(k):
  for j in range(1, l[l2[i]]+1):
    ans += j/l[l2[i]]
     
print(ans)

Submission status: Wrong Answer

Solution code:
P = []
S = []
N, K = map(int, input().split())
P = input().split(' ')
P = [int(t) for t in P]
for i in range(N-K+1):
	sum = 0
	for k in range(K):
		sum = sum + P[i+k]
	S.append(sum)
id = S.index(max(S))

ex = 0
for k in range(K):
	idk = id + k
	for p in range(P[idk]):
		ex = ex + (p + 1) * (1 / P[idk])
print(int(ex))

Submission status: Wrong Answer

Solution code:
def main():
    
    n,k = map(int, input().split())
    
    p_list = list(map(int, input().split()))

    p_list_sorted = sorted(p_list, reverse=True)
    #print(p_list)

    sort_index = [p_list.index(s) for s in p_list_sorted]
    #print(sort_index)
    ans = 0
    if k == 1:
        ans = (max(p_list)+1)*0.5
    else:
        for j in sort_index[:(n-k)]:
            ans_tmp = 0
            if j+k > n-1:
                j = n-k
            for i in range(k):
                ans_tmp += (p_list[i+j]+1)*0.5
            if ans_tmp >= ans:
                ans = ans_tmp

    print(ans)

    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    
    n,k = map(int, input().split())
    
    p_list = list(map(int, input().split()))

    #p_list.sort(reverse=True)
    #print(p_list)

    ans = 0
    for j in range(n-k):
        ans_tmp = 0
        for i in range(k):
            ans_tmp += (p_list[i+j]+1)*0.5
        if ans_tmp >= ans:
            ans = ans_tmp

    print(ans)

    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
Q.append(S[0])
q=0
for i in range(N-K):
    q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))

Submission status: Wrong Answer

Solution code:
import math

M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
q=0

for i in range(N-K+1):
   for j in range(K):
       a=P[i+j]
       q=q+M[a]
   Q.append(q)
   q=0

print(Q)
print(max(Q))

Submission status: Wrong Answer

Solution code:
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]

D = sum(P[:K])
index = 0

for i in range(1, N - K + 1):
    if D + P[i + K - 1] - P[i - 1] > D:
        D = D + P[i + K - 1] - P[i - 1]
        index = i

ans = (sum(P[index: index+K]) + K) / 2

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]

D = sum(P[:K])
index = 0

for i in range(1, N - K + 1):
    if D + P[i + K - 1] - P[i - 1] > D:
        D = D + P[i + K - 1] - P[i - 1]
        index = i

ans = 0

for i in range(K):
    ans += (1 + P[index + i]) / 2

print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*(len(d)+1)

# 累積和の計算
w[0] = 0
for i in range(0, len(d)):
  w[i+1] = w[i] + d[i]
print(w)
ans = 0
for i in range(0, a-b+1):
    ans = max([ans,w[i+b]-w[i]])

d2 = 0.5*b + ans/2

if a == 1:
  print((d[0]+1)/2)
else:
  print(d2)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*len(d)

  

# 累積和の計算
w[0] = d[0]
for i in range(1, len(d)):
  w[i] = w[i-1] + d[i]

  
ans = 0
for i in range(1, a-b):
    ans = max([ans,w[i+b]-w[i]])
  
  
d2 = 0.5*b + ans/2

if a == 1:
  print((d[0]+1)/2)
else:
  print(d2)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
d = list(map(int, input().split(" ")))
w = [0]*len(d)

# 累積和の計算
w[0] = d[0]
for i in range(1, len(d)):
  w[i] = w[i-1] + d[i]

ans = 0
for i in range(a-b):
    ans = max([ans,w[i+b]-w[i]])
d2 = 0.5*b + ans/2

print(d2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=0
for i in range(k):
  b+=a[i]

ma=b
for i in range(n-k):
  b+=a[k]
  b-=a[i]
  ma=max(b,ma)

ans=(ma+k)/2

Submission status: Wrong Answer

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

sum_tmp = sum(a[:k])
sum_max = sum_tmp
for i in range(3,len(a)):
    sum_tmp += a[i] - a[i-k]
    if sum_tmp > sum_max:
        sum_max = sum_tmp
print((sum_max + k)/2)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
n, k = map(int, input().split())
a = list(map(int, input().split()))

sum_tmp = Decimal(sum(a[:3]))
sum_max = Decimal(sum_tmp)
for i in range(3,len(a)):
    sum_tmp += a[i] - a[i-k]
    if sum_tmp > sum_max:
        sum_max = sum_tmp
print((sum_max + k)/2)

Submission status: Wrong Answer

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

sum_tmp = sum(a[:3])
sum_max = sum_tmp
for i in range(3,len(a)):
    sum_tmp += a[i] - a[i-k]
    if sum_tmp > sum_max:
        sum_max = sum_tmp
print((sum_max + k)/2)

Submission status: Wrong Answer

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

p_e = [ (x + 1) * 0.5 for x in p]
p_p = [p_e[0]]

for i in range(1, n):
    p_p.append(p_p[i-1] + p_e[i])

e_sum = [p_p[i] - p_p[i - k] for i in range(n - k + 1)]
print(max(e_sum))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
lst = list(map(int, input().split()))
ans = []
for i in lst:
  ans.append((i*(i+1)//2)/i)
ans = sum(lst[:M])
max_ans = ans
num = 0
for i in range(M, N):
  ans = ans - lst[num] + lst[i]
  num += 1
  if ans > max_ans:
    max_ans = ans
print(max_ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=list(map(int,input().split()))
e=[float((1+i)/2) for i in p]
ans=0
new=0
for i,v in enumerate(e):
	new=sum(e[:i+1+K])-sum(e[:i+1])
	if ans<new:
		ans=new
print(ans)

Submission status: Wrong Answer

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

pi = [0 for _ in range(n)]
si = [0 for _ in range(n)]

pi = [int(s) for s in input().split()]
pi = [(1+s)/2 for s in pi]

si[0] = pi[0]
for i in range(1,n):
    si[i] = si[i-1] + pi[i]

#print(pi)
#print(si)
#print(si[2]-si[0])

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

print(float(ans))

Submission status: Wrong Answer

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

pi = [0 for _ in range(n)]
si = [0 for _ in range(n)]

pi = [int(s) for s in input().split()]
pi = [(1+s)/2 for s in pi]

si[0] = pi[0]
for i in range(1,n):
    si[i] = si[i-1] + pi[i]

#print(pi)
#print(si)
#print(si[2]-si[0])

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

print(ans)

Submission status: Wrong Answer

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

E = []
for i in P:
    E.append((i + 1)/2)

print(E)

Submission status: Wrong Answer

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

sign = 0
max = 0
for i in range(N-K+1):
    suming = 0
    for j in range(K):
        suming += P[i+j]
    if suming > max:
        max = suming
        sign = i
print(sign)

def expect(p):
    return float(sum(range(1, p+1))/p)

extra = 0
for k in range(K):
    numb = sign + k
    extra += expect(P[numb])

print(extra)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
dice = list(map(int, input().split()))
expected_accum = []
ans = 0
for i in range(len(dice)):
    if i == 0:
        expected_accum.append((dice[i] + 1) / 2)
    else:
        expected_accum.append(expected_accum[i - 1] + (dice[i] + 1) / 2)

for i in range(len(dice) - K):
    ans = max(ans, expected_accum[i + K] - expected_accum[i])

print(ans)

Submission status: Wrong Answer

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

def sm(lst, j, k):
  return lst[j+k]-lst[j]

def max(lst, k):
  sumlst = [lst[0]]
  for i in range(1, len(lst)):
    sumlst.append(sumlst[i-1]+lst[i])
  res = 0
  for i in range(N-k):
    if res < sm(sumlst, i, k):
      res = sm(sumlst, i, k)
  res = (res+k)/2
  return res

print(max(List, K))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    import sys
    
    i = list(map(int, input().split()))
    N = i[0]
    K = i[1]
    
    p = list(map(int, sys.stdin.readline().split()))
    max_s = 0
    s_current = 0
    
    for i in range(N - K + 1):
        if i == 0:
            p_list = p[:]
            max_s = sum(p_list)
            s_current = max_s
        else:
            s_current = s_current - p[i - 1] + p[i + K - 1]
            if s_current > max_s:
                max_s = s_current
        
    ans = (max_s + K) / 2.0
    print(ans)

Submission status: Wrong Answer

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

m = [(e + 1) / 2 for e in range(N)]

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

Submission status: Wrong Answer

Solution code:
from itertools import accumulate

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

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

sum=0
temp=0
for i in range(0,K):
  temp+=pp[i]
for i in range(0,N-K):
  sum=max(temp,temp-pp[i]+pp[i+K])
  temp=temp-pp[i]+pp[i+K]
print(sum)

Submission status: Wrong Answer

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

pp=[0]*N
for i in range(N):
    pp[i]=(p[i]+1)/2
pp.sort()
sum=0
for i in range(0,K):
    sum+=pp[i]
for i in range(0,N-K):
    sum=max(sum,sum-pp[i]+pp[i+K])
print(sum)

Submission status: Wrong Answer

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

pp=[0]*N
for i in range(N):
    pp[i]=(p[i]+1)/2
sum=0
for i in range(0,K):
    sum+=pp[i]
for i in range(0,N-K):
    sum=max(sum,sum-pp[i]+pp[i+K])
print(sum)

Submission status: Wrong Answer

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

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

print((max+K)//2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)*0.500000000000000000

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
for i in range(n-k):
  a.append(a[i]+g(p[k])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        for i in range(n-k+1):
            cal = sum(p1[i:i+k-1])
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[a[0]]
for i in range(1,n):
    b.append(b[-1]+a[i])
max=0
for j in range(k,len(b)):
    if max<b[j]-b[j-k]:
        max=b[j]-b[j-k]
print((max+k)/2)

Submission status: Wrong Answer

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


def calc(value):
    return value * (value + 1) / value


max_value = 0
for i in range(k):
    max_value += calc(p[i])

cur = max_value
for l in range(k, n):
    cur += (calc(p[i]) - calc(p[l]))
    max_value = max(max_value, cur)
print(max_value)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

exp = []
for i in range(N):
    exp.append((1 + P[i]) / 2)

cum_exp = np.cumsum(exp)

max = cum_exp[0]
for i in list(range(K, N)):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

exp = []
for i in range(N):
    exp.append((1 + P[i]) / 2)

cum_exp = np.cumsum(exp)

max = 0
for i in range(K - 1, N):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

exp = []
for i in range(N):
    exp.append((1 + P[i]) / 2)

cum_exp = np.cumsum(exp)

max = 0
for i in range(K, N):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

cum_exp = np.cumsum(exp)

max = 0
for i in range(K, N):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)

Submission status: Wrong Answer

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

print(m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
a = 0
sum1 = 0
sumMax = 0
for i in range(N):
    a += p[i]
    S.append(a)
for i in range(N-K+1):
    sum1 = S[i+K] - S[i]
    print(sum1)
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
p = list(map(int,input().split()))
S = []
a = 0
sum1 = 0
sumMax = 0
for i in range(N):
    a += p[i]
    S.append(a)
for i in range(N-K):
    sum1 = S[i+K] - S[i]
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]*(N+1)
Kmax=-1
for i in range(N):
    Q[i+1]+=P[i]+Q[i]

for j in range(N-K+1):
    print(Q[j+K]-Q[j])
    if Q[j+K]-Q[j]>Kmax:
        Kmax=Q[j+K]-Q[j]
print((Kmax+K)/2)

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
list = [int(i) for i in input().split()]
sumlist = []
sum = 0;ans = 0
for l in range(n):
    list[l] = (1+list[l])/2

for i in range(n):
    sum += list[i]
    sumlist.append(sum)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
list = [int(i) for i in input().split()]
s = 0
for l in range(n):
    for i in range(list[l]+1):
        s += i
    i = 0
    list[l] = s/list[l]
    s = 0

sum = 0

for i in range(k):
    sum += list[i]

if k!=n:
    for j in range(k,n):
        sum = max(sum,sum+list[j]-list[j-k])
    print(sum)
else:
    print(sum)

Submission status: Wrong Answer

Solution code:
import decimal

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

exps = []
for i in l1:
    s = 0
    for j in range(1,i+1):
        s = s + j
    a_exp = decimal.Decimal(s/i)
    exps.append(a_exp)
print(exps)

sums = []
for i in range(n-k+1):
    a_sum = 0
    for j in range(k):
        a_sum += exps[i+j]
    sums.append(a_sum)
    
print(max(sums))

Submission status: Wrong Answer

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

exps = []
for i in l1:
    s = 0
    for j in range(1,i+1):
        s = s + j
    a_exp = s/float(i)
    exps.append(a_exp)
print(exps)

sums = []
for i in range(n-k+1):
    a_sum = 0
    for j in range(k):
        a_sum += exps[i+j]
    sums.append(a_sum)
    
print(max(sums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A ,B = [int(x) for x in input().split()]
C = [(int(x)+1)/2 for x in input().split()]
ans = 0
count = 0
D = [0]*A
sum = 0
for i in range(A):
    sum += C[i]
    D[i] = sum
    if i >= B:
        dif = sum - D[i-B]
        if dif > ans:
            ans = dif
    
print(ans)

Submission status: Wrong Answer

Solution code:
A ,B = [int(x) for x in input().split()]
C = [(int(x)+1)/2 for x in input().split()]
ans = 0
count = 0
D = [0]*A
sum = 0
for i in range(A):
    sum += C[i]
    D[i] = sum
    if i > B:
        dif = sum - D[i-B]
        if dif > ans:
            ans = dif
    
print(ans)

Submission status: Wrong Answer

Solution code:
A ,B = [int(x) for x in input().split()]
C = [(int(x)+1)/2 for x in input().split()]
ans = 0
count = 0
for i in range(A-B):
    for j in range(B):
        count += C[i+j]
    if count > ans:
        ans = count
    count = 0
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
    P[i]=0.5*(P[i]+1)
x=sum(P[:k])
s=[x]

for i in range(1,n-k):
    x=x-P[i-1]+P[i+k]
    s.append(x)

print(max(s))

Submission status: Wrong Answer

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

s=[]
x=sum(P[:k])
for i in range(1,n-k):
    if x<x-P[i-1]+P[i+k]:
        x=x-P[i-1]+P[i+k]

print(x)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
lst=map(int,input().split())
lst_sum=[(i+1)*0.5 for i in lst]

lst_grandsum=[]
grandsum=0
for i in lst_sum:
    grandsum+=i
    lst_grandsum.append(grandsum)
    
max_ans=0
for j in range(len(lst_grandsum)):
    if j<len(lst_grandsum)-k:
        ans=lst_grandsum[j+k]-lst_grandsum[j]
        max_ans=max(max_ans,ans)
print(max_ans)

Submission status: Wrong Answer

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

pmax = [i for i in range(n) if p[i] == max(p)]

q = [sum([j for j in range(1, p[i]+1)])/p[i] for i in range(n)]

if pmax[0] - k >= 0:
   s = pmax[0] - k
else:
   s = 0
if pmax[-1] + k >= n:
   t = n + 1
else:
   t = pmax[-1] + k

maxe = 0
for i in range(s, t-k):
   e = 0
   for j in range(i, i+k):
      e += q[j]
   maxe = max(maxe, e)

print(maxe)

Submission status: Wrong Answer

Solution code:
nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]

p = [int(s) for s in input().split()]
r = 0
l = []

for x in range(n-k):
  if p[x] <= p[x+k]:
    if r == 0:
      r = 1
  else:
    if r == 1:
      l.append(x)
    r = 0
    
if len(l) > 0:
  s = [sum(p[y:y+k]) for y in l]
  print((max(s)+k)/2)
else:
  if p[0] <= p[-1]:
    print((sum(p[n-k:])+k)/2)
  else:
    print((sum(p[:k-1])+k)/2)

Submission status: Wrong Answer

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

sum_max = 0
for i in range(k - 1, n):
    if i == k - 1:
        sum_now = sum(ps[:i + 1])
    else:
        sum_now = sum_now + ps[i] - ps[i - k]
    print(sum_now)
    sum_max = max(sum_max, sum_now)
    
print(float(sum_max + k) / 2)

Submission status: Wrong Answer

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

sum_max = 0
for i in range(k - 1, n):
    if i == k - 1:
        sum_now = sum(ps[:i + 1])
    else:
        sum_now = sum_now + ps[i] - ps[i - k]
    print(sum_now)
    sum_max = max(sum_max, sum_now)
    
print((sum_max + k) / 2)

Submission status: Wrong Answer

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

exs = []
for p in ps:
  exs.append((1.0+p)/2)
exs = sorted(exs)
print(sum(exs[-k:]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def wa(n):
    if n<=1:
        return 1
    else:
        return wa(n-1)+n

if __name__ == "__main__":
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    b=[]
    for i in a:
        b.append((i+1)/2)
    max=0
    for i in range(len(b)-k):
        sum=0
        for j in range(i,i+k):
            sum+=b[j]
        if max<=sum:
            max=sum
    print(max)

Submission status: Wrong Answer

Solution code:


n,k=map(int,input().split())
#p=np.array(list(map(int,input().split())))
p=list(map(int,input().split()))
def kitaichi(a):
  s=(1+a)/2.
  return s
kp=list(map(kitaichi,p))

#for z in range(0,k):
#	buf[z]=sum(buf[z:k+z])
buf=[0]*(n-k+1)
buf[0]=sum(kp[:k])
if n != k:
  for z in range(1,k):
    buf[z]=buf[z-1]-kp[z-1]+kp[z+k-1]
    #buf=[sum(kp[x:k+x]) for x in range(0,int(k/15))]
maxkp=max(buf)
print(maxkp)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_kitai = [p/2 for p in P]

max_kitai = 0
for i in range(N - K + 1):
    res = sum(P_kitai[i:i+K])
    max_kitai = max(max_kitai, res)
print(max_kitai)

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = [0]
    for i in range(len(p_list)):
        sum_list.append(p_list[i]+sum_list[i])
    # print(sum_list)
    for i in range(len(p_list)-k+1):
        # print(sum_list[i+k], sum_list[i])
        if max_sum < sum_list[i+k-1]-sum_list[i-1]:
            max_sum = sum_list[i+k-1]-sum_list[i-1]
        
    return (max_sum+k)/2.0

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

print(float(dice_in_line(k, p_list)))

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = []
    for i in range(len(p_list)):
        if i == 0:
            sum_list.append(p_list[i])
        else:
            sum_list.append(p_list[i]+sum_list[i-1])
    for i in range(len(p_list)-k):
        if max_sum < sum_list[i+k]-sum_list[i]:
            max_sum = sum_list[i+k]-sum_list[i]
        
    return (max_sum+k)/2.0

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

print(float(dice_in_line(k, p_list)))

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = []
    for i in range(len(p_list)):
        if i == 0:
            sum_list.append(p_list[i])
        else:
            sum_list.append(p_list[i]+sum_list[i-1])
    for i in range(len(p_list)-k+1):
        if max_sum < sum_list[i+k-1]-sum_list[i-1]:
            max_sum = sum_list[i+k-1]-sum_list[i-1]
        
    return (max_sum+k)/2.0

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

print(float(dice_in_line(k, p_list)))

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = []
    for i in range(len(p_list)):
        if i == 0:
            sum_list.append(p_list[i])
        else:
            sum_list.append(p_list[i]+sum_list[i-1])
    for i in range(len(p_list)-k+1):
        if max_sum < sum_list[i+k-1]-sum_list[i-1]:
            print(sum_list[i+k-1])
            print(sum_list[i-1])
            max_sum = sum_list[i+k-1]-sum_list[i-1]
        
    return (max_sum+k)/2.0

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

print(float(dice_in_line(k, p_list)))

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    for i in range(len(p_list)-2):
        if sum(p_list[i:i+k]) > max_line[-1]:
            max_line = p_list[i:i+k]
            max_line.append(sum(max_line[0:k]))
    return (max_line[-1]+k)/2.0

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

print(float(dice_in_line(k, p_list)))

Submission status: Wrong Answer

Solution code:
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    for i in range(len(p_list)-2):
        print(i)
        if sum(p_list[i:i+k]) > max_line[-1]:
            max_line = p_list[i:i+k]
            max_line.append(sum(max_line[0:k]))
    return (max_line[-1]+k)/2.0

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

print(dice_in_line(k, p_list))

Submission status: Wrong Answer

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

print (ans)