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()))
max_i = 0
t = sum(p[:k])
for i in range(k,n):
  if t+p[i]-p[i-k] > t:
    t = t+p[i]-p[i-k]
    max_i = i-k+1
  
ans = sum([sum(range(p_+1))/p_ for p_ in p[max_i:max_i+k]])
print(ans)

Submission status: Wrong Answer

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

max_p = max(p)
max_p_index = p.index(max_p)
# print(max_p_index)
p = p[max_p_index - (K - 1): max_p_index + (K - 1)]

sum_l = 0
sum_p = 0
sum_p_len = []
max = 0

for i in range(len(p) - K + 1):
    l = p[i:K]
    sum_l = sum(l)
    if max < sum_l:
        max = sum(l)
        sum_p_len = l
    K += 1

# print(sum_p_len)

sum = 0

for i in sum_p_len:
    for j in range(i):
        j += 1
        sum += j / i
    sum_p += sum
    sum = 0

print(sum_p)

Submission status: Wrong Answer

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

cnt=0
s=sum(p[0:k])
for i in range(n-k):
    tmp = s-p[i]+p[i+k]
    print(tmp)
    if s < tmp:
        cnt = i+1
        s = tmp

ans=0
for i in range(cnt, cnt+k):
    ans += (1+p[i])*p[i]/2/p[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
tmp = 0
for i,l in enumerate(lis):
    if i+k <= len(lis)-1:
        #print(i,k)
        if lis[i+k]>l:
            tmp = i+1
#print(tmp)
#print(new_lis)
#print(lis[tmp:tmp+k])
print(sum([(ll+1)/2 for ll in  lis[tmp:tmp+k]]))
#print((sum(lis[tmp:tmp+k])+k)/2)

Submission status: Wrong Answer

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

s = [0]*n
hai = [0]*n
max = 0

print(s)
for i in range(n):
  for j in range(4):
   t = sum(hai[(i-j):(i+k-j)])
   if max < t :
      max = t
print(max)

Submission status: Wrong Answer

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

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

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

print(round(value, 6))

Submission status: Wrong Answer

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

R = []

for x in L:
   a = sum(L[x:K + x])
   R.append(a)

max_v = max(R)
max_i = R.index(max_v)

print(sum(L[max_i:max_i + K]) + K/2)

Submission status: Wrong Answer

Solution code:
def sgm(i):
    sum=0
    for j in range(i+1):
        sum+=j
    return sum

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

print(sum)

Submission status: Wrong Answer

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

a = []
for i in p:
  if i == 1:
    a.append(1)
  else:
    a.append(((i-1)/2) + 1)

A = 0
for i in range(n-k):
  s = sum(a[i:i+k])
  if A < s:
    A = s
print(A)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
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] = ((Decimal(p[i])*(Decimal(p[i])+1))/2)/Decimal(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('{:.10f}'.format(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
if N == K:
    print((sum(ilist)+K)/2)
else:
    while True:
        s = max_dice - ilist[i] + ilist[i+K]
        if s > max_dice:
            max_dice = s
            ind = i + 1
        if i == N-K-1:
            break
        else:
            i += 1
    max_p = (sum(ilist[ind:ind+K])+K)/2
    print(max_p)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
List = list(map(int,input().split()))
result = [(1+i)/2 for i in List]
Answer = 0
base = [sum(result[0:K])]
for i in range(N-K):
  counter = base[i]-result[i]+result[i+K]
  if counter > Answer:
    Answer = counter
  base.append(counter)

print(Answer)

Submission status: Wrong Answer

Solution code:
n, k, *p = map(int, open(0).read().split())

p = tuple(p)
max_r = 0
max_i = 0
pre = 0
for i in range(n-k+1):
  if pre > p[i+k-1]:
    continue
  r = sum(p[i:i+k])
  pre = p[i]
  
  if r > max_r:
    max_r = r
    max_i = i
    
max_e = 0
for j in range(max_i, max_i+k):
  max_e += (p[j]+1)/2

print(max_e)

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)/2
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
        c = B
        A = B

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
l = [(int(i)+1)/2 for i in input().split()]

st = sum(l[:b])
temp = st
max = 0
for i in range(b,a):
  temp = temp + l[i] - l[i-b]
  if max < temp:
    max = temp
    
print(max)

Submission status: Wrong Answer

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

iti = p.index(max(p))
temp = 0
for i in range(iti-K+1,iti+K):
    if temp < sum(p[i:i+K]):
        iti = i
        temp = sum(p[i:i+K])
        
ans = 0
for j in p[iti:iti+K]:
    ans += (j+1)/2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

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

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

p_a = 0
p_r = p[:k]
for j in p_r:
    if j == 1:
        p_a += 1
    else:
        p_a += (j + 1) / 2

for i in range(1, n-k+1):
    p_b = p_a
#     print(str(p[i-1]))
#     print(str(p[i+k-1]))
    if (p[i-1] == 1):
        p_b -= 1
    else:
        p_b -= (p[i-1] + 1) / 2
#         print(str((p[i-1] + 1) / 2))
#         print(str(p_b))

    if (p[i+k-1] == 1):
        p_b += 1
    else:
        p_b += (p[i+k-1]  + 1) / 2
#        print(str((p[i+k-1] + 1) / 2))
#        print(str(p_b))
    if p_b > p_a:
#         print(str(i))
        p_a = p_b
print(p_a)

Submission status: Wrong Answer

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

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))
    
    if A[0] == 1 and len(A) == 1:
        return 1
    
    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())
ilist = list(map(int,input().split()))
max_dice = sum(ilist[:K])
ind = 0
i = 0
if N == K:
    print(sum(ilist))
else:
    while True:
        s = max_dice - ilist[i] + ilist[i+K]
        if s > max_dice:
            max_dice = s
            ind = i + 1
        if i == N-K-1:
            break
        else:
            i += 1
    max_p = (sum(ilist[ind:ind+K])+K)/2
    print(max_p)

Submission status: Wrong Answer

Solution code:
#import heapq

def dice(p):
    sum = 0
    for i in range(1,p+1):
        sum += i/p
    return sum

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

m = 0
l = []
for i in range(n-k+1):
    t = sum(p[i:i+k])
    if(m <= t):
        l = p[i:i+k]
        m = t
print(l)
#l = heapq.nlargest(k, p)
#print(l)


dist = {}
res = 0
for i in l:
    if i in dist:
        ans = dist[i]
    else:
        dist[i] = dice(i)
    res += dice(i)

print(res)

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+1,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:
a,b = map(int, input().split())
l = [(int(i)+1)/2 for i in input().split()]

st = sum(l[:b])
temp = st
max = 0
for i in range(b,a):
  temp = temp + l[i] - l[i-b]
  if max <= temp:
    max = temp
    
print(max)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
tmp = 0
for i,l in enumerate(lis):
    if i+k <= len(lis)-1:
        #print(i,k)
        if lis[i+k]>l:
            tmp = i+1
#print(tmp)
#print(new_lis)
#print(lis[tmp:tmp+k])
print((sum(lis[tmp:tmp+k])+k)/2)

Submission status: Wrong Answer

Solution code:
n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda x: sum(x)/len(x)+1, map(range, dices)))
s = sum(avg[0:t])

for i in range(1, n-t+1):
  s = max(s, s - avg[i-1] + avg[i+t-1])
print(s)

Submission status: Wrong Answer

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

prev = sum(p[1:k])
current = 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:
        current = 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 = list(map(int, input().split()))
  
m = sum(p[0: k])
sump = m

for i in range(1, n-k+1):
  sump = sump - p[i-1] + p[i+k-1]
  print(sump)
  if m < sump:
    m = sump

ans = (m + k) / 2

print(ans)

Submission status: Wrong Answer

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

saidai = 0
gokei = sum(p[0:K])
#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(float((saidai+K)/2))

Submission status: Wrong Answer

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

expectation=[]
E = []

#期待値
for t in p:
    value = 0
    for x in range(t+1):
        value += x/t
    E.append(value)
print(E)

for t in range(N-(K-1)):
    value = 0
    for i in range(K):
        value += E[t+i]
    expectation.append(value)

output = sorted(expectation,reverse=True)
print(format(output[0],'.12f'))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
pi = list(map(int, input().split()))
#期待値列
E=[(p+1)/2 for p in pi]
F=[]
cal=0
for i in range(N-K+1):
    F.append(cal)
    cal=0
    for j in range(K):
        cal += E[i+j]
print(float(max(F)))

Submission status: Wrong Answer

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

each_sum_list = []
ex_sum = 0
for i in range(N - K + 1):
    K_sum = 0
    if i == 0:
        K_sum = sum(p[0:K])
    else:
        K_sum = ex_sum - p[i - 1] + p[i + K - 1]
        ex_sum = K_sum

    each_sum_list.append(K_sum)
list_index = each_sum_list.index(max(each_sum_list))

kitaichi = 0

for i in p[list_index:list_index + K]:
    kitaichi += (0.5 * i * (i + 1) / i)

print(kitaichi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
E = [0]*N

for i in range(N-K+1,N):
  E[i] = (p[i]+1)/2

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

Submission status: Wrong Answer

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

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

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

print(round(value, 12))

Submission status: Wrong Answer

Solution code:
N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  expected_list.append(int(p[i])*(int(p[i])+1)/2)
  
for i in range(N):
  anan = 0
  for j in range(K):
    try:
      anan += expected_list[i+j]
    except:
      pass
  max_list.append(anan)
  
print(max(max_list))

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
p = list(map(int, input().split()))
lists = list()
x = n[0] - n[1] + 1

for i in range(x):
  lists.append(sum(p[i:i+n[1]]))
  
print ((n[1] + max(lists) /2))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
n,k=map(int,input().split())
p=list(map(Decimal,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, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda x: sum(x)/len(x)+1, map(range, dices)))
s = sum(avg[0:t])
print(s)

for i in range(1, n-t+1):
  s = max(s, s - avg[i-1] + avg[i+t-1])
print(s)

Submission status: Wrong Answer

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

def su(n):
  return n*(n+1)/2

maxind=0
maxsum=0
for i in range(n-k):
  if p[i+k] > p[i]:
    m = sum(p[i:i+k-1])
    if m > maxsum:
      maxind = i+1
s = 0
for i in range(k):
  s += su(p[maxind+i])/p[maxind+i]
print(s)

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))
    
    if A[0] == 1 and len(A) == 1:
        return 1
    
    ans = 0
    for i in range(M, N):
        ans = max(ans, l[i] - l[i-M])
    
    print(ans)
    ans = (ans+M) / 2
    
    return ans

print(solve())

Submission status: Wrong Answer

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

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 == 0:
    kitaichi_sum[i] = kitaichi[i]
  elif i >= k-1:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
    if kitaichi_sum[i] > ans:
      ans = kitaichi_sum[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()))
memo = sum(P[:K])
ans = -1

for i in range(K, N):
    memo = memo - P[i-K] + P[i]
    ans = max(ans, memo)

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

Submission status: Wrong Answer

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

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


b = sum(dice[0: k])

res = 0
ll = 0
s = 0
mmm = range(k, len(dice))
for i in mmm:
    ss = sum(dice[i:i + k])
    if ss > b:
        b = ss
        ll = i
    s += 1

for mn in range(ll - k + 1, ll + 1):
    ss = range(dice[mn] + 1)
    res += sum(ss) / dice[mn]
print(res)

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)
elif n == d:
  ans = np.array(a)
  ans = ans*0.5 + 0.5
  print(sum(ans))
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])
      ans = 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:
def main():
    N,K = map(int, input().split())
    A = list(map(int,input().split()))
    P=[0]*N
    for i in range(N):
        P[i]=(A[i]+1)/2
    max=0
    check=0
            
    for j in range(K):
        check +=P[j]

    for i in range(K,N):
        check +=P[i]
        check -=P[i-K]

        if check > max:
            max=check
    print(max)
main()

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)/2
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)/2)

print(ans)

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

sum = dol/2 + 0.5*a

print(sum)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)
E = 0
for t in range(K):
    value = 0
    for x in range(p[t]):
        value += (x+1)/p[t]
    E += value
print(format(E,'.12f'))

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(float(saidai+K)/float(2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

NK=K
mo=1

answer=np.max([mo*np.sum(p[i:i+NK]) for i in range(NK)]) / 2 + NK/2

print(abs(answer) )

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(float(saidai+K)/float(2))

Submission status: Wrong Answer

Solution code:
import decimal

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

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

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

print(round(value, 12))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
tmp = 0
for i,l in enumerate(lis):
    if i+k <= len(lis)-1:
        #print(i,k)
        if lis[i+k]>lis[i]:
            tmp = i+1
#print(tmp)
#print(new_lis)
print((sum(lis[tmp:tmp+k])+k)/2)

Submission status: Wrong Answer

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

s = [0]*n
hai = [0]*n
max = 0

for i in range(n):
  hai[i] = (sum(range(int(tmp[i])))+int(tmp[i]))/int(tmp[i])
print(s)
for i in range(n):
  for j in range(4):
   t = sum(hai[(i-j):(i+k-j)])
   if max < t :
      max = t
print(max)

Submission status: Wrong Answer

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


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


def ex(n):
    return sum(list(range(1, n+1))) / n

# main
N, K = mis()
p = lmis()

exs = [0] * N

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

if N == K:
    print(sum(exs))
    exit(0)

p_ex_max = max(exs)
ex_max = 0
for i in range(N):
    if exs[i] == p_ex_max:
        for j in range(i-K, i):
            ex_temp = 0
            for kk in range(j, j+K):
                if 0 <= kk < N:
                    ex_temp += exs[kk]

            if ex_max < ex_temp:
                ex_max = ex_temp

"""
for i in range(N-K+1):
    ex_temp = 0
    for j in range(i, i+K):
        ex_temp += exs[j]

    if ex_max < ex_temp:
        ex_max = ex_temp
"""
print(ex_max)

Submission status: Wrong Answer

Solution code:
def calc_ap(num):
    dice = []
    ex = 0
    for no in range(num):
        dice.append(no + 1)

    pex = 1 / len(dice)

    for x in dice:
        px = pex*x
        ex += px

    return ex


n, k = map(int, input().split())
p_list = list(map(int, input().split()))
s = 0
for i in range(k):
    s = s + p_list[i]
p = 0
for i in range(len(p_list) - k + 1):
    st = 0
    for j in range(i, i + k):
        st = st + p_list[j]
    if s < st:
        p = i

sum_ex = 0
for m in range(p, p + k):
    sum_ex = sum_ex + calc_ap(p_list[m])

print(sum_ex)

Submission status: Wrong Answer

Solution code:
N,K = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  sum = int(p[i])*(int(p[i])+1)/2
  expected_list.append(float(sum/(int(p[i]))))
  
for i in range(N):
  anan = 0
  for j in range(K):
    try:
      anan += expected_list[i+j]
    except:
      pass
  max_list.append(anan)

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('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    ans = [0] * N
    max_tmp = [0] * K
    start_index = 0
    for i in range(N - K + 1):
        tmp = P[i: i + K]
        ans[i] = sum(list(range(1, P[i] + 1))) / P[i]
        if sum(max_tmp) < sum(tmp):
            start_index = i

    for i in range(N - K, N):
        ans[i] = sum(list(range(1, P[i] + 1))) / P[i]

    print(sum(ans[start_index: start_index + K]))


resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
exp=tuple(map(lambda x: (int(x)+1)/2,input().split()))
l=np.cumsum(exp)
ans=0
for i in range(0,n-k):
  x=l[i+k]-l[i]
  ans=max(ans,x)
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
  
x = 0
m = 0
sump = sum(p[0: k])

for i in range(1, n-k+1):
  sump = sump - p[i-1] + p[i+k-1]
  if m < sump:
    m = sump

ans = (m + k) / 2

print("{0:.12f}".format(ans))

Submission status: Wrong Answer

Solution code:

def main():
    n,k = map(int,input().split())
    lst = list(map(int,input().split()))
    r = create_ruisekiwa(lst)
    i = mx_index(lst,k)
    #print(i)
    print(sum(map(dice_kitaichi,lst[i:i+k])))

def create_ruisekiwa(lst):
    ruisekiwa = [0] * (len(lst))
    for i in range(0,len(lst)):
        ruisekiwa[i] = ruisekiwa[i-1] + lst[i]
    return [0] + ruisekiwa

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

def mx_index(lst,k):
    r = create_ruisekiwa(lst)
    mx = 0
    index = 0
    #print(len(lst) - k)
    for i in range(1,len(r)-k):
        temp = r[i+k] - r[i-1]
        if temp > mx:
            mx = temp
            index = i
    return index






if __name__ == '__main__':
    main()
    pass

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
p=list(map(int,input().split()))
ans=0
for j in  range(1,N-K+1):
    temp=0
    temp+=(0.5*(sum(p[j:j+K])+K))
    if temp>ans:
        ans=temp
print(ans)

Submission status: Wrong Answer

Solution code:
def get_sum_largest_subarray_fixed_length(vec, veclen):
  largest_so_far = 0
  for idx, _ in enumerate(vec[:-veclen-1]):
    current_size = sum(vec[idx:idx+veclen])
    largest_so_far = max(largest_so_far, current_size)
  return largest_so_far

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

expected_value_list = [val*(val+1)/(2*val) for val in p]
print(get_sum_largest_subarray_fixed_length(expected_value_list, K))

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
l = [(int(i)+1)/2 for i in input().split()]
l.append(0)

st = sum(l[:b])
temp = st
max = 0
for i in range(b,a-b+1):
  temp = temp + l[i] - l[i-b]

  if max < temp:
    max = temp
    
print(max)

Submission status: Wrong Answer

Solution code:
import math

# 入力、宣言
N,K=map(int,input().split())
intList=list(map(int,input().split()))
Intsum=0

result=0

# 処理
# 一番右のさいころから逆算して期待値を算出
for i in range(len(intList),len(intList)-K,-1):
    j=0
    Intsum=0
    while j<=intList[i-1]:
        Intsum+=j
        j+=1
    result+=Intsum/(intList[i-1])

# 出力
print(result)

Submission status: Wrong Answer

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

max_e = 0
l = [0] * N

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

for i in range(N - K + 1):
    e = 0
    for j in range(K):
        e += l[j]
    if e > max_e:
        max_e = e

print(max_e)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
tmp = 0
for i,l in enumerate(lis):
    if i+k <= len(lis)-1:
        #print(i,k)
        if lis[i+k]>lis[tmp]:
            tmp = i+1
#print(tmp)
#print(new_lis)
print((sum(lis[tmp:tmp+k])+k)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
pi = list(map(int, input().split()))
#期待値列
E=[(p+1)/2 for p in pi]
F=[]
cal=0
for i in range(N-K+1):
    F.append(cal)
    cal=0
    for j in range(K):
        cal += E[i+j]

print((max(F)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    StringN,StringK = input().split();
    ListA           = input();
    newListA        = ListA.split();
    temp            = 0;
    max             = 0;
    maxK            = 0;
    Kitaichi        = 0;
    i               = 0;
    j               = 0;
    #隣接するK個の最大値を求める
    for i in range(len(newListA) - int(StringK) + 1):
        j = i;
        temp = 0;
        for j in range(j, j + int(StringK)):
            temp = temp + int(newListA[j]);
            print(temp)
        if max < temp:
            max = temp;
            maxK = i;
            print(max);


    #隣接するK個の期待値を求める
    for i in range(maxK, maxK + int(StringK)):
        Kitaichi = Kitaichi + (1 + int(newListA[i])) / 2;

    print(Kitaichi);

main();

Submission status: Wrong Answer

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

p_n = input().split()

up_to = n - k + 1

result = 0.0

for i in range(n):
    p_n[i] = (1 + int(p_n[i]))/2

sum_ex = 0.0

for i in range(k):
    sum_ex += p_n[i]

for i in range(1,up_to):
    if p_n[i-1] < p_n[i+k-1]:
        sum_ex = 0.0
        for j in range(i,i+k):
            #print(p_n[j])
            sum_ex += p_n[j]
            
    if(result < sum_ex):
        result = sum_ex


print('{0:.6f}'.format(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_index_list = [i for i, x in enumerate(p_list) if x == max(p_list)]

max_ex_value = 0
for max_index in max_index_list :
  for i in range(max_index-k+1,max_index-1):
    x = 0
    for j in range(0, k):  
      x += (p_list[i+j]+1)/2
    if x >= max_ex_value:
      max_ex_value = x
               
print(max_ex_value)