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:
inf = int(1e9+7)
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    n, k = [int(x) for x in raw_input().split()]
    
    arr = [(1 + float(x)) / 2 for x in raw_input().split()]
    
    if k == 1:
        print(max(arr))
        return
    
    #print(arr)
    """
    total = sum(probs)
    
    arr = [0] * n
    
    for i in range(n):
        arr[i] = float(i) * (probs[i] / total)
    
    print(arr)
    """
    
    pref_sum = [0] * n
    
    pref_sum[0] = arr[0]
    
    for i in range(1, n):
        pref_sum[i] = pref_sum[i-1] + arr[i]
    
    max_sub = -inf
    
    for end in range(k, n):
        start = end - k
        cur = pref_sum[end] # - pref_sum[start-1]
        if start > 0:
            cur -= pref_sum[start-1]
        if cur > max_sub:
            max_sub = cur
        
    
    
    print(max_sub)

main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
print((sum(p[n-k:])+k)/2)

Submission status: Wrong Answer

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

for i in range (0, N):
	A[i] = (A[i]+1)/2

print(A)

sumK = sum(A[0:K])

L = [sumK]

for i in range (0, N-K):
	sumK = sumK + A[K+i] - A[i]
	L.append(sumK)

print(max(L))

Submission status: Wrong Answer

Solution code:
N,K= map(int, input().split())
List = list(map(int, input().split()))
num=0
s=0
for i in range(K):
    s+=(List[i]+1)
num=0
#print(s)
if N==K:
    print(s/2)
    
for i in range(N-K):
    a=List[i+K]-List[i]
    #print(a)
    n1=s+a
    s=n1
    n1=n1/2
    if n1>=num:
        num=n1
print(num)

Submission status: Wrong Answer

Solution code:
N,K= map(int, input().split())
List = list(map(int, input().split()))
num=0
s=0
for i in range(K):
    s+=(List[i]+1)
num=0
#print(s)
for i in range(N-K):
    a=List[i+K]-List[i]
    #print(a)
    n1=s+a
    s=n1
    n1=n1/2
    if n1>=num:
        num=n1
print(num)

Submission status: Wrong Answer

Solution code:
# 初期入力
#import numpy as np
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
p = list(map(int, input().split()))

expected_value =[(i+1)/2 for i in p] #各さいころの期待値

#隣接する数列の和
adjacent_sum =[0]*N
adjacent_sum[0] =sum(expected_value[:K])
ans =[0]*N
ans[0] =adjacent_sum[0]/K
for i in range(1,N-K+1):
    adjacent_sum[i] =adjacent_sum[i-1] -expected_value[i-1] +expected_value[i+K-1]
    ans[i] =adjacent_sum[i] 
print(max(ans))

Submission status: Wrong Answer

Solution code:
def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result

a,b=map(int,input().split())
c=list(map(int,input().split()))

if a==b:
    print((sum(c)+a)/a)
    exit()
d=[]

c=[(i+1)/2 for i in c]
n=cumsum(c)

m=[]
for i in range(0,a-b):
    m.append(n[i+b]-n[i])


print(max(m))

Submission status: Wrong Answer

Solution code:
def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result

a,b=map(int,input().split())
c=list(map(int,input().split()))

if a==b:
    print((sum(c)+a)/a)
    exit()
d=[]

c=[(i+1)/2 for i in c]
n=cumsum(c)
print(n)
m=[]
for i in range(0,a-b):
    m.append(n[i+b]-n[i])


print(max(m))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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-k+1):
    a = 0
    for j in range(i, i+k):
        a += (p[j]*(1+p[j]))/2/p[j]
    ans = min(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
plist = list(map(int,input().split()))
psum = [0]*n
psum[0] = plist[0] + 1
for i in range(1,n):
    psum[i] = psum[i-1] + plist[i] + 1


mx = 0
for i in range(1,n-k+1):
    delta = psum[i+k-1] - psum[i-1]
    if mx < delta:
        mx = delta
print(mx/2)

Submission status: Wrong Answer

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

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

from itertools import accumulate
B = list(accumulate(A))
#print(A)

ans = 0
if len(A) == K:
    ans = sum(A)/2
else:
    for i in range(K,N):
        ans=max(ans,(A[i]-A[i-K])/2)
print(ans)

Submission status: Wrong Answer

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

s = [0] * n
s[0] = b[0]
for x in range(1, n):
    s[x] = s[x - 1] + b[x]
res = 0
for x in range(n - k):
    res = max(res, s[x + k] - s[x])

print("{:.10f}".format(res))

Submission status: Wrong Answer

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

s = [0] * n
s[0] = b[0]
for x in range(1, n):
    s[x] = s[x-1] + b[x]
res = 0
for x in range(n - k):
    res = max(res, s[x+k] - s[x])

print("{:.6f}".format(res))

Submission status: Wrong Answer

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

s = [0] * n
s[0] = (b[0]+1)/2
for x in range(1, n):
    s[x] = s[x-1] + (p[x]+1)/2
res = 0
for x in range(n - k):
    res = max(res, s[x+k] -s[x])

print("{:.6f}".format(res))

Submission status: Wrong Answer

Solution code:

n, k = input().split()
m = list(map(int, input().split()))
ans = 0
kazu =[]
kai = []
kazu = [(a+1) /2 for a in m]
kitai = sum(kazu[0:int(k)])

for x in range(int(n) - int(k)):
    kitai -= kazu[x]
    kitai += kazu[x + int(k)]
    if ans < kitai:
        ans = kitai

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N,K =map(int,input().split())
p = list(map(int,input().split()))
ans = 0
ss = list(accumulate(p))

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

Submission status: Wrong Answer

Solution code:
N,K =map(int,input().split())
p = list(map(int,input().split()))
ans = 0
ss = [sum(p[0:i+1]) for i in range(N)]

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

Submission status: Wrong Answer

Solution code:
from collections import deque, defaultdict

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

dice = [0]
for i in range(1000):
  dice.append(1 + 0.5 * i)
  
lis = []
sum = 0
for p in P:
  sum += dice[p]
  lis.append(sum)
  
ans = 0
for i in range(N - K):
  ans = max(ans, lis[K+i] - lis[i])
print(ans)

Submission status: Wrong Answer

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

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

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

print((ans+k)/2)

Submission status: Wrong Answer

Solution code:

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

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

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

print((ans+k)/2)

Submission status: Wrong Answer

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

ps = list(map(lambda x: int(x) + 1, input().split()))



from collections import deque

q = deque()

tmp = sum(ps[:k])

q.append(tmp)



ps

for i in range(n-k):
    print(i)
    tmp = tmp - ps[i] + ps[k+i]
    q.append(tmp)



q

print(max(q)/2)

Submission status: Wrong Answer

Solution code:
import numpy as np
import numpy

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

S = numpy.cumsum(P)
P.append(0)
M = S[0]

for i in range(0,N):
    if P[i+K] == 0:
        break
    A = S[i+K] - S[i]
    M = max(M, A)

ans = 0.5 * (M + K)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import numpy

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

S = numpy.cumsum(P)
P.append(0)

for i in range(0,N):
    if P[i+K] == 0:
        break
    A = S[i+K] - S[i]
    M = max(M, A)

ans = 0.5 * (M + K)

print(ans)

Submission status: Wrong Answer

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

S = sum(P[0:K])

for i in range(1,N):
    if P[i+K-1] == 0:
        break
    B = P[i-1:i+K]
    S = S - B[0] + B[K]
    M = max(M, S)

ans = 0.5 * (M + K)

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


n, k = map(int, input().split())
p = list(map(int, input().split()))
max_sum_k = 0
cum_sum = list(accumulate(p))
for i in range(k-1, n):
    sum_p = cum_sum[i] - cum_sum[i-k]
    if sum_p > max_sum_k:
        max_sum_k = sum_p

max_ex = (k + max_sum_k) / 2
print(max_ex)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
pp = list(map(int,input().split()))
s=[0]*n
for i,p in enumerate(pp):
  if i==0:
    s[0] = (1+p)/2
  else:
    s[i] = s[i-1]+(1+p)/2
res =0 
for i in range(n-k):
  if res < s[i+k] - s[i]:
    res = s[i+k]-s[i]
print(res)

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
pp=list(map(int,input().split()))
exs=[0] * n
mx_dx=0
mx=0
cont=0
for i,p in enumerate(pp):
  exs[i] = (1+p)/2
  if mx < exs[i]:
    mx_dx = i
    mx = exs[i]
    cont = 1
  elif mx == exs[i]:
    if mx_dx + 1 == i:
      cont+=1
if cont >= k:
  print(mx*k)
  sys.exit()
res=mx*cont
ran=[mx_dx,mx_dx+cont-1]
for i in range(n-cont+1):
  if ran[1]-ran[0] + 1 == k:
    break
  if ran[0] == 0:
    res += exs[ran[1]+1]
    ran[1] += 1
    continue
  if ran[1] == n-1:
    res += exs[ran[0]-1]
    ran[0] -= 1
    continue
  if ran[0] > 0 and exs[ran[0]-1] > exs[ran[1]+1]:
    res += exs[ran[0]-1]
    ran[0] -= 1
  elif ran[1] < n and exs[ran[0]-1] < exs[ran[1]+1]:
    res += exs[ran[1]+1]
    ran[1] += 1
  elif ran[1] -ran[0] > k:
    res += exs[ran[0]-1]*2
    ran[0] -=1
    ran[1] +=1
  else:
    res += exs[ran[0]-1]
    break
print(res)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
pp=list(map(int,input().split()))
exs=[(1+p)/2 for p in pp]
exsum = sum(exs)
ran=[0,n-1]
for i in range(n):
  if ran[1]-ran[0]+1 == k:
    break
  if exs[ran[0]] > exs[ran[1]]:
    exsum -= exs[ran[1]]
    ran[1] -=1
  elif exs[ran[1]] > exs[ran[0]]:
    exsum -= exs[ran[0]]
    ran[0] += 1
  elif ran[1] -ran[0] > k:
    exsum -= exs[ran[0]]*2
    ran[0] += 1
    ran[1] -= 1
    i += 1
  else:
    exsum -= exs[ran[0]]
    break
print(exsum)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
pp=list(map(int,input().split()))
exs=[(1+p)/2 for p in pp]
exsum = sum(exs)
ran=[0,n-1]
for i in range(n):
  if ran[1]-ran[0]+1 == k:
    break
  if exs[ran[0]] > exs[ran[1]]:
    exsum -= exs[ran[1]]
    ran[1] -=1
  else:
    exsum -= exs[ran[0]]
    ran[0] += 1
print(exsum)

Submission status: Wrong Answer

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

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ref = sum(p[:k])
    ans = ref

    for i in range(1, n - k):
        minus = p[i - 1]
        plus = p[i + k - 1]
        ref = ref - p[i - 1] + p[i + k - 1]
        if ref > ans:
            ans = ref

    print(ans/2 + k*0.5)

main()

Submission status: Wrong Answer

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

start = P.index(max(P))

for i in range(1, K+1):
    if start+i-K < 0 or start+i > len(P):
        continue
    e = 0
    for j in range(start+i-K, start+i):
        e += (P[j] + 1) / 2
    max_e = max(e, max_e)

print(max_e)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=sum(S[0:K])
tempsum=maxsum

for i in range(K,N-K):
    tempsum=tempsum-S[i]+S[i+K]
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass

print(maxsum)

Submission status: Wrong Answer

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

start = P.index(max(P))
end = start

while (end - start + 1) < K:
    if start == 0:
        end += 1
    elif end == len(P) - 1:
        start -= 1
    else:
        if P[start - 1] >= P[end + 1]:
            start -= 1
        else:
            end += 1

for i in range(start, end+1):
    e += (P[i] + 1) / 2

print(e)

Submission status: Wrong Answer

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

# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S[:-K+1])):  #ここがrange(len(S)-K)ではダメっぽいのがわからない・・・
    tempSKsum=sum(S[i:i+K])
    if maxSKsum<tempSKsum:
        maxSKsum=tempSKsum
        startSindex=i
    else:
        pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EV+=tempEV

print(EV)

Submission status: Wrong Answer

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


# K個連続した区間での最大が期待値の最大として、SでK個連続した最大値を探す。
maxSKsum=0
startSindex=0

#1.大きい区間を探す
for i in range(len(S[:-K])):
    if S[i]<S[i+K]:
        pass
    else:
        tempSKsum=sum(S[i:i+K])
        if maxSKsum<tempSKsum:
            maxSKsum=tempSKsum
            startSindex=i
        else:
            pass

#2.1で探した大きい区間の計算をする。
EV=0
for s in range(K):
    tempEV=(S[startSindex+s]+1)/2
    EV+=tempEV

print(EV)

Submission status: Wrong Answer

Solution code:
from collections import deque

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



first = P[0:K]
max_sum = 0
current_sum = sum(first)
q = deque(first)

for p in P[K:N]:
    left = q.popleft()
    q.append(p)
    current_sum = current_sum - left + p
    if max_sum < current_sum:
        max_sum = current_sum

ans = (max_sum + K) / 2

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append(int(s))

# K=4
# S=[17, 13, 13, 12, 15, 20, 10, 13, 17, 11]
# K=3
# S=[1,2,2,4,5]

EVlist=[]

for i in range(len(S)):
    tempEV=(S[i]*(S[i]+1))/2/S[i]
    EVlist.append(tempEV)

maxEVsum=0

for j in range(len(EVlist)-K):
    tempEVsum=sum(EVlist[j:j+K])
    if maxEVsum<tempEVsum:
        maxEVsum=tempEVsum

print(maxEVsum)

Submission status: Wrong Answer

Solution code:
from collections import deque

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



first = P[0:K]
max_sum = 0
current_sum = sum(first)
q = deque(first)

for p in P[:N-K+1]:
    left = q.popleft()
    q.append(p)
    if left < p:
        current_sum = sum(q)
    if max_sum < current_sum:
        max_sum = current_sum

ans = (max_sum + K) / 2

print(ans)

Submission status: Wrong Answer

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

exp = [0]
for p in P:
  exp.append(exp[-1]+(1+p)/2)

res = 0
for i in range(K,N):
  res = max(res, exp[i]-exp[i-K])

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort(reverse=True)
kitai = [0] * n
for i in range(n):
    kitai[i] += (p[i] + 1) / 2
print(sum(kitai[:k]))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
maximum=sum(P[:K])
num=0
for i in range(N-K):
    m=maximum-P[i]+P[i+K]
    if m>=maximum:
        num=i+1
        maximum=m
print(sum([1+(p-1)*0.5 for p in P[num:num+K]]))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
maximum=sum(P[:K])
num=0
for i in range(N-K):
    m=maximum-P[i]+P[i+K]
    if m>=maximum:
        num=i+1
print(sum([1+(p-1)*0.5 for p in P[num:num+K]]))

Submission status: Wrong Answer

Solution code:
def main():
    N,K = map(int, input().split())
    P = list(map(int, input().split()))
    S = [0]*(N)

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

    S[0]=P[0]
    for i in range(1,N):
        S[i] = S[i-1] + P[i]

    m = -1
    for i in range(N-K):
        m = max(m,S[i+K]-S[i])

    print(m/2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

exv = [(e+1)/2 for e in dices]
temp = sum(dices[0:K])
result = temp
for i in range(N-K):
    temp -= dices[i]
    temp += dices[i+K]
    if temp > result:
        result = temp
print(result)

Submission status: Wrong Answer

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

lst=[0]
sum=0
for i in range(n):
    sum+=p[i]
    lst.append(sum)
    
ans=[]
for i in range(n-k+1):
    ans.append(lst[i+k]-lst[i])

print(lst,ans,(max(ans)+k)/2)

Submission status: Wrong Answer

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

E = [(1+p)/2 for p in P]
S = [0]
for i in range(len(E)):
    S.append(S[i] + E[i])
print(S)
for j in range(3, len(S)):
    ans = max(ans, S[j]-S[j-3])
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=[int(i) for i in input().split()]
a=[]
ans=0
for i in p:
    ans+=(i+1)/2
    a.append(ans)
k=0
for t in range(0,N-K):
    tt=a[t+K]-a[t]
    k=max(k,tt)
print(k)

Submission status: Wrong Answer

Solution code:
# 和の期待値は期待値の和
# それぞれ期待値を出したあとは大きさKの区間和の最大値
# n(n+1)/2
n, k = map(int, input().split())
p = []
for x in list(map(int, input().split())):
    p.append((x * (x + 1) // 2) / x)

ans = 0
tmp = 0
for i in range(n):
    tmp += p[i]
    if i >= k:
        tmp -= p[i - k]
        ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
L = []
D = 0
for k in range(K):
    l = P.pop(len(P)-1)
    L.append(l)
for l in L:
    O = sum(range(1, l+1))
    D = D + (O / l)
print(D)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
if K == 1:
    temp = max(p)
    siguma = 0.5*p[0]*(p[0]+1)
    kitaiti = siguma/float(p[0])
    print(kitaiti)
else:
    old_x = p[:K]
    temp1 = sum(old_x)
    for i in range(1,N-K+1):
        x = p[i:i+K]
        temp2 = sum(x)
        if temp1 < temp2:
            old_x = x
            temp1 = temp2
    res = 0
    for i in old_x:
        siguma = 0.5*float(i)*(float(i)+1)
        res += siguma/i
    print(res)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
if K == 1:
    temp = max(p)
    siguma = 0.5*p[0]*(p[0]+1)
    kitaiti = siguma/float(p[0])
    print(kitaiti)
else:
    old_x = p[:K]
    for i in range(1,N-K+1):
        x = p[i:i+K]
        if sum(old_x) < sum(x):
            old_x = x
    res = 0
    for i in old_x:
        siguma = 0.5*float(i)*(float(i)+1)
        res += siguma/i
    print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans=sum([exp(i) for i in p[:k]])
bk=ans
for i in range(1, n-k+1):
    start=i-1
    end=start+k
    newans=bk-exp(p[start])+exp(p[end])
    ans=max(ans,newans)

print(ans)

Submission status: Wrong Answer

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

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

ans=sum([exp(i) for i in p[:k]])
for i in range(1, n-k+1):
    start=i-1
    end=start+k
#    print(start, end)
#    print(p[start], p[end])
    newans=ans-exp(p[start])+exp(p[end])
#    print(ans, newans)
    ans=max(ans,newans)

print(ans)

Submission status: Wrong Answer

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

arr = sorted(arr)
ex = 0 
for x in range(n-k,n):
    for j in range(1,arr[x]+1):
        ex += j/arr[x]
print(ex)

Submission status: Wrong Answer

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


s = sum(p[:k])
m = s
j = 0
for i in range(n-k):
    s = s-p[i] + p[i+k]
    if s > m:
        m = s
        j = i

print((sum(p[j+1:j+k+1]) + k) / 2)

Submission status: Wrong Answer

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

from itertools import accumulate
E = [(1+p)/2 for p in P]
ES = list(accumulate(E))

e = 0
for i in range(N-K):
    e = max(e, (ES[K+i] - ES[i]))
print(e)

Submission status: Wrong Answer

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

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

e = 0
for i in range(N-K):
    e = max(e, (ES[K+i] - ES[i]))
print(e)

Submission status: Wrong Answer

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

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

e = 0
for i in range(N-K):
    e = max(e, (ES[K+i] - ES[i]))
print(e)

Submission status: Wrong Answer

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

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

from itertools import accumulate
ES = list(accumulate(E))

e = 0
for i in range(N-K):
    e = max(e, (ES[K+i] - ES[i]))
print(e)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    #input
    N,K=map(int,input().strip().split())
    P=list(map(int,input().strip().split()))
    
    #期待値行列
    E=list(map(lambda x:(x+1)*x//2/x,P))
    S=[0 for n in range(N-K+1)]
    for n in range(K):
        S[0]+=E[n]
    
    ans=0
    for i in range(1,N-K+1):
        S[i]=S[i-1]-E[i-1]+E[i+K-1]
        ans=max(ans,S[i])
    print(ans)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

l = list(map(int, input().split()))
l = [(i+1)/2 for i in l]

ls = [0, l[0]]
for i in range(1, n):
    ls.append(ls[-1]+l[i])

if n == 1:
    print((l[0]+1)/2)
else:
    lans = [ls[i+k]-ls[i] for i in range(len(ls)-k)]
    print(max(lans))

Submission status: Wrong Answer

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

lis = list()

p = [(i + 1)/2 for i in p ]
numpy.set_printoptions(precision=16)

cumSum = numpy.cumsum(p)

print(p)
cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.12f}'.format(max(lis)))

Submission status: Wrong Answer

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

lis = list()

p = [(i + 1)/2 for i in p ]
numpy.set_printoptions(precision=16)

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.12f}'.format(int(max(lis))))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)
numpy.round(cumSum2, 12)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.12f}'.format(int(max(lis))))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.18f}'.format(int(max(lis))))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.12f}'.format(int(max(lis))))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.08f}'.format(int(max(lis))))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    print(i)
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.08f}'.format(max(lis)))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print(int(max(lis)))

Submission status: Wrong Answer

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

lis = list()

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

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    print(i)
    lis.append(cumSum2[K+i] - cumSum2[i])

print(max(lis))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())
    p = np.array(list(map(int, input().split())), dtype='f8')
    p = (p + 1) / 2
    rs = np.zeros(N + 1, dtype='f8')
    for i in range(N):
        rs[i + 1] = rs[i] + p[i]
    ans = 0
    for i in range(N - K):
        ans = max(ans, rs[i + K] - rs[i])

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())
    p = np.array(list(map(int, input().split())), dtype='f4')
    p = (p + 1) / 2

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

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    n, k = map(int, input().split())
    from itertools import accumulate
    A = list(map(int, input().split()))
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成
    num=0
    val=0
    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
    for i in range(k, n + 1):
        if B[i]-B[i-k+1]>val:
            val=B[i]-B[i-k+1]
            num=i

    ans = 0
    for j in A[num-k:num]:
        ans += (0.5 * j * (1 + j)) / j
    print(ans)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# i番目の期待値は(1/p_i)*(sum(1からp_iまでの和)))

def get_E(x):
    return (sum(list(range(1,x+1))))/x

E_list = [get_E(p_i) for p_i in p]

# 累積和(Cumulative sum)
S = [E_list[0]]
for i in range(1, n):
    S.append(S[i-1]+E_list[i])

ans = -1

i = 0
while i+k < n:
    ans = max(ans, S[i+k]-S[i])
    i += 1

print(ans)

Submission status: Wrong Answer

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

# i番目の期待値は(1/p_i)*(sum(1からp_iまでの和)))

def get_E(x):
    return (sum(list(range(1,x+1))))/x

E_list = [get_E(p_i) for p_i in p]

# 累積和(Cumulative sum)
S = [E_list[0]]
for i in range(1, n):
    S.append(S[i-1]+E_list[i])

ans = -1

i = 0
while i+k < n:
    print(i)
    ans = max(ans, S[i+k]-S[i])
    i += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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