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:
# abc 154
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

# 期待値一覧の作成
expected_dict = {k:cal_expected(k) for k in set(P)}

from collections import deque
# 対象特定
dices = []
dices_sum = 0
tmp_dices = None
for start in range(1, N-K+1):
    if tmp_dices == None:
        tmp_dices = deque(P[start:start+K])
    else:
        tmp_dices.popleft()
        tmp_dices.append(P[start+K-1])
    tmp_sum = sum(tmp_dices)
    if tmp_sum > dices_sum:
        dices = tmp_dices
        dices_sum = tmp_sum

# 期待値計算
# answer = sum(map(cal_expected, dices))
answer = 0
for dice in dices:
    answer += expected_dict[dice]
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy

n,k = map(int,input().split())
p = list(map(int,input().split()))
q = []
for i in range(n):
    q.append(((((p[i]+1)*p[i])/2)/p[i]))
res = numpy.cumsum(q)
print(q)
ans = []
ans.append(q[k-1])
for i in range(k,n):
  ans.append(res[i]-res[i-k])
print(max(ans))

Submission status: Wrong Answer

Solution code:

def K(n):
    return 0.5 * (n + 1)

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

    pionta = None
    ire = [None for i in range(k)]
    for i in range(0, n):
        if k < i + 1:
            pionta = i % k
        if pionta is None:
            ire[i] = p[i]
        else:
            if ire[pionta] < p[i]:
                ire[pionta] = p[i]
    m = 0
    for i in ire:
        m += K(i)
    return m
print(d())

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
#python3

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

def main():
    n, k = map(int, input().split())
    fp = [f(int(i)) for i in input().split()]
    n = len(fp)
    v = sum(fp[0:k])
    i = 0
    ans = 0
    while i+k <= n-1:
        v = v-fp[i]+fp[i+k] 
        ans = max(ans, v)
        i+=1

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

main()

Submission status: Wrong Answer

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

max = 0
ite = N - K + 1
base = sum(p[0:K])
max = base
index = 0
for i in range(ite):
    tmp = base+p[i+K-1]-p[i]
    if tmp > max:
        max = tmp
        index = i


E = [None]*K
for i in range(K):
    E[i] = sum(range(1, p[index+i]+1))/p[index+i]
print(sum(E))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p1 = np.array(p)
p1 = (p1 + 1)/2

sums = [0]*k
for i in range(k):
    sums[i] = np.sum(p1[i:i+k])

print(np.max(sums))

Submission status: Wrong Answer

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

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



print(ans)

Submission status: Wrong Answer

Solution code:

def K(n):
    return 0.5 * (n + 1)

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

    pionta = None
    print(p)
    ire = [None for i in range(k)]
    for i in range(0, n):
        if k < i + 1:
            pionta = i % k
        if pionta is None:
            ire[i] = p[i]
        else:
            if ire[pionta] < p[i]:
                ire[pionta] = p[i]
    m = 0
    for i in ire:
        m += K(i)
    return m
print(d())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
if len(list(set(P))) == 1:
  print((P[0] + 1) / 2)
  exit()
sums = []
for i in range(N - K + 1):
  sums.append(sum(P[i:i + K]))
sums.sort()
print((sums[-1] + K) / 2)

Submission status: Wrong Answer

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

exv = np.zeros(len(p)) 
for i in range(len(p)):
    exv_d = [1/p[i]*j for j in range(p[i]+1)]
    exv[i] = sum(exv_d)

if K == 1:
    print(sorted(exv, reverse=True)[0])
else:
    d = sorted(exv, reverse=True)[0:K]
    print(sum(d))

Submission status: Wrong Answer

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

total_expects = []
# 1回のサイコロについて
for i in range(0, n):    
    # 1個のサイコロの期待値リスト
    expect = [q * (1 / p[i]) for q in range(1, p[i]+1)]
    total_expects.append(sum(expect))

print(max([sum(total_expects[i:i+k]) for i in range(0, k)]))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = a[0] - a[1]
e = 0
for i in range(0,d+1):
	if e < sum(b[i:i+a[1]]):
		e = sum(b[i:i+a[1]])
	else:e = e
print(e)

Submission status: Wrong Answer

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

number_list = []

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

print('{:.12f}'.format(float(sum_max)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

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

for k in p_list:
    for l in range(k):
        wa += (l+1)/k

print(wa)

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K-2]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)

Submission status: Wrong Answer

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

maxstart = 0
maxval = 0
nowval = 0
for i in range(K):
  nowval += p[i]
maxval = nowval
  
for i in range(N-K-1):
  nowval -= p[i]
  nowval += p[i+K]
  if nowval > maxval:
    maxval = nowval
    maxstart = i+1

ans = 0
for i in range(K):
  ans += (p[i+maxstart] + 1)

print(ans/2)

Submission status: Wrong Answer

Solution code:
x=0
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
for i in range(N):
  S.append((1+P[i])/2)
#print(S)
i=1
while i+K<N+1:
  #T.append(sum(S[i:i+K]))
  x=max(x,sum(S[i:i+K]))
  i=i+1
#print(S)
#print(T)
print("{0:.12f}".format(x))

Submission status: Wrong Answer

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

def calc(n):
    return sum([i for i in range(1, n+1)]) / n

ex = []
for i in p:
    ex.append(calc(i))

max_ex = 0
for i in range(0, N-2):
    temp = ex[i] + ex[i+1] + ex[i+2]
    if temp >= max_ex:
        max_ex = temp

print(max_ex)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int, input().split()))
cnt=0
for i in range(N):
    if K+i<=N:
        if cnt<=sum(A[i:K+i]):
            B=A[i:K+i]
res=[]
for b in B:
    tmp=0
    for i in range(1,b+1):
        tmp+=(i/b)
    res.append(tmp)
print(sum(res))

Submission status: Wrong Answer

Solution code:
import numpy
a,b = map(int,input().split())
li = list(map(int,input().split()))
L = [(i**2+i)/(2*i) for i in li]
dp=[0]*a
res = numpy.cumsum(L)
dp[0] = res[b-1]-res[0]
for i in range(1,a-b+1):
    dp[i] = res[i+b-1]-res[i-1]
print(max(dp))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
P = [int(i) for i in input().split()]

if k == 1:
    m = max(P)
    print((m+1)/2)

else:
    Pa = [(1+h)/2 for h in P]
    if n == k:
        print(sum(Pa))
    else:
        sm = sum(Pa[:k])
        r_ind = k-1
        r_res = k-1
        l_ind = 0
        l_res = 0
        s = sm
        while r_ind < n - 1:
            right = Pa[r_ind + 1]
            left = Pa[l_ind + 1]
            s += right
            s -= left
            if sm < s:
                sm = s
                l_res = l_ind
                r_res = r_ind
            r_ind += 1
            l_ind += 1
    
        m = 0
        for k in Pa[l_res+1:r_res+2]:
            m += k
    
        print(m)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = A[-K:]
print((1/2)*(sum(B)+K))

Submission status: Wrong Answer

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

list=sorted(p,reverse=True)

i=0
r=0

while(i<k):
  a=list[i]
  j=0
  while(j<a):
    r=1/a*a
    j+=1
  i+=1

print(r)

Submission status: Wrong Answer

Solution code:
def calc_expected_value(n):
    # sum_n = [i for i in range(1, n+1)]
    # return sum(sum_n) / n
    return n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
ans = 0.0

for i in range(n-k_range+1):
    e = sum([calc_expected_value(p[i+k]) for k in range(k_range)])
    ans = max(ans, e)

print(ans)

Submission status: Wrong Answer

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

e = []

for i in range(n):
  a = p[i] * (p[i] + 1) / 2
  e.append(a/p[i])

ans = sum(e[0:k])
s = ans
print(e)
for i in range(k,n):
  aaa = s + e[i] - e[i-k]
  if ans < aaa:
    ans = aaa
  s = aaa
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
 
a = [0]*(N-K+1)
f = sum(p[:K])
a[0] = f

for i in range(N-K):
    f = f + p[i+K] - p[i]
    a[i+1] = f
##print(a)
num = 0

for i in range(1,N-K+1):
    if a[i] >= a[i-1]:
        num = i
ans = 0
##print(num)
##print(p[num:num+K])

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

print(ans)

Submission status: Wrong Answer

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

def E(a):
    return a*(a+1)/2/a

box=[]
for i in range(k):
    s = sum(p[i:i+k])
    box.append(s)
    if i+k == len(p)+1:
        break
ok = box.index(max(box))
new_p = p[ok:ok+k]
ans = sum([E(i) for i in new_p])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
a,b = map(int,input().split())
li = list(map(int,input().split()))
L = [(i**2+i)/(2*i) for i in li]
dp=[0]*a
res = numpy.cumsum(L)
dp[0] = res[b-1]-res[0]
for i in range(1,a-b+1):
    dp[i] = res[i+b-1]-res[i-1]
print(max(dp)/b)

Submission status: Wrong Answer

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

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

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

print(sum(l))

Submission status: Wrong Answer

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

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])
dp=[0 for _ in range(N)]

M,mi=0,0
for i in range(N-K+1):
    s=sum(p[i:i+K+1])
    if s>M:
        M=s
        mi=i
print(ex3(p[mi+1:mi+K+1]))

Submission status: Wrong Answer

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

total_expects = []
# 1回のサイコロについて
for i in range(0, n):    
    # 1個のサイコロの期待値リスト
    expect = [q * (1 / p[i]) for q in range(1, p[i]+1)]
    total_expects.append(sum(expect))

max_k_expect = 0
for i in range(0, k):
    if max_k_expect < sum(total_expects[i:i+k]):
        max_k_expect = sum(total_expects[i:i+k])
print(max_k_expect)

Submission status: Wrong Answer

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

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

print(sum1)

Submission status: Wrong Answer

Solution code:
def judge(x, y):
  if x < 0 or y < 0:
    return True
  if P[x] > P[y]:
    return True
  if P[x] == P[y]:
    return judge(x-1, y-1)
  return False

N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
for i in range(1, N - K + 1):
  if judge(i+K-1, i-1):
    start = i
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)

Submission status: Wrong Answer

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

ans_max = 0
max_num = 0
max_index = 0

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

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

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

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

Submission status: Wrong Answer

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

exp_v = []
for dice in p:
    val = 0
    for i in range(1,dice+1):
        val += i
    exp_v.append(val/dice)

ans = 0

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

Submission status: Wrong Answer

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

tmp = [sum(list(range(1,i+1)))/i for i in P]

res = 0.0
for k in list(range(N-K)):
    res1 = sum(tmp[k:K+k])
    if res < res1:
        res = res1

print(res)

Submission status: Wrong Answer

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

s=0
m=sum(P[0:K])
for i in range(len(P)-K):
  m=m-P[i]+P[i+K]
  if m>s:
    s=m
  

l=(s+K)/2
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline

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

dp = np.zeros(200000, dtype='int16')
ans = 0
for i in range(N - K + 1):
    tmp = np.array([dp[i], np.sum(p[i:i + K])])
    dp[i+1] = tmp.max()

print((dp[N-K+1] + K) / 2)

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

input_arr = input().split(" ")
arr = []


max = 0
tmp = 0
if(K > 1):
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        arr.append(ex)
        tmp += ex
        if(i >= K-1):
            if(max <= tmp):
                max = tmp
            tmp -= arr[i-K-1]
else:
    for i in range(N):
        pi = int(input_arr[i])
        ex = (1+pi)/2
        if(ex > max):
            max = ex
print(max)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
maxsumP = -1
resP = []
for i in range(N-K+1):
  PP = P[i:K+i]
  mp = sum(PP)
  if maxsumP < mp:
    resP = PP
    maxsumP = mp
res = 0
print(res)

Submission status: Wrong Answer

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

tmp = sum(ps[:k])
max_ps = tmp
start = 0

for i in range(1,n-k):
    tmp = tmp-ps[i-1]+ps[i+k-1]
    if tmp >= max_ps:
        max_ps = tmp
        start = i

print(sum([(i*(i+1))/ (2*i) for i in ps[start:start+k]]))

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
x = list(map(int, input().split()))

basyo=0
for i in range(A-B):
    if x[i]<x[i+B]:
        basyo=i+1
wa=sum(x[basyo:basyo+B])
kotae=(wa+B)/2
print(kotae)

Submission status: Wrong Answer

Solution code:

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

p_shift = p[k:] + [0] * k

con_p = [0] * dices
sum_first_k = sum(p[0:k])

con_p[0] = sum_first_k

for i in range(dices-k):
    con_p[i+1] = con_p[i] + p_shift[i] - p[i]

max_expectation = (k + max(con_p))/2.
print(con_p)
print(max_expectation)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = map(int, input().split())
p = input().split()
p = [int(i) for i in p]
# p = [((int(i)+1)/2) for i in p]
arr_1d = np.array(p)
SUM_P = []
for i in range(N-K+1):
    SUM_P.append(np.sum(p[i:i+K]))
print((max(SUM_P)+1)/2)

Submission status: Wrong Answer

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

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])

dp=[0 for _ in range(N)]

M,mi=0,0
for i in range(N-K+1):
    s=sum(p[i:i+K+1])
    if s>M:
        M=s
        mi=i
print(mi)
print(ex3(p[mi+1:mi+K+1]))

Submission status: Wrong Answer

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

answer = []
for i in range(0,N):
    #print(list(range(1,p[i]+1)))
    ev = sum(range(1,p[i]+1))/p[i]
    answer.append(ev)
total = 0
print(answer)
for i in range(0,N):
    if len(answer[i:i+K])==K:
        total = max(total, sum(answer[i:i+K]))
print(total)

Submission status: Wrong Answer

Solution code:
def kitai(num):
    k = 0.0000000000
    for ni in range(1, num + 1):
        k += ni / num
    return k

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

max_sum = 0
ind = 0
for i in range(n-k+1):
    tmp_sum = sum(p[i:i+k])
    if(max_sum < tmp_sum):
        ind = i

nums = p[ind: ind+k]

r = 0.0000000000
for num in nums:
    r += kitai(num)

print(r)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
P = [int(i) for i in input().split()]

if k == 1:
    m = max(P)
    print((m+1)/2)

else:
    Pa = [(1+h)/2 for h in P]
    sm = sum(Pa[:k])
    r_ind = k-1
    r_res = k-1
    l_ind = 0
    l_res = 0
    s = sm
    while r_ind < n - 1:
        right = Pa[r_ind + 1]
        left = Pa[l_ind + 1]
        s += right
        s -= left
        if sm < s:
            sm = s
            l_res = l_ind
            r_res = r_ind
        r_ind += 1
        l_ind += 1

    m = 0
    for k in Pa[l_res+1:r_res+2]:
        m += k

    print(m)

Submission status: Wrong Answer

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

maxstart = 0
maxval = 0
nowval = 0
for i in range(K):
  nowval += p[i]
maxval = nowval
  
for i in range(N-K-1):
  nowval -= p[i]
  nowval += p[i+K]
  if nowval > maxval:
    maxval = nowval
    maxstart = i+1

ans = 0
for i in range(K):
  ans += (p[i+maxstart] + 1)/2
print(ans)

Submission status: Wrong Answer

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

exp = 0e0
max = 0e0
maxi = -1

#for l in range(n):
    #print(p[-(l+1)])
    #exp += (0.5*p[-(l+1)]*(p[-(l+1)]+1))/p[-(l+1)]
    #p[l] = 0.5*(p[l]+1)

for l in range(n-k):
    exp += p[l]
    if(exp > max):
        max = exp
        maxi = l

out = 0
for aa in range (maxi,maxi+k):
    out += 0.5*(p[aa]+1)

print(out)

Submission status: Wrong Answer

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

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        now_sum += p_list[p_i + i]

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = []
for i in range(k):
    max_scope_list.append(p_list[scope_index + i])
print(max_scope_list)

ex = 0
for scope in max_scope_list:
    for num in range(1, scope+1):
        ex += num*1/scope
print(ex)

Submission status: Wrong Answer

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



def calc(x):
    for i in range(x,x+K):
        sum_p = sum_p + p[i]
        #print(sum_p)
    return sum_p

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

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

Submission status: Wrong Answer

Solution code:
def calc(A):
    res = 0
    res = (1+A)/2
    return res
    
N, K = map(int, input().split())
P = list(map(int, input().split()))
res = 0
ind = 0
part = sum(P[0:K])

for i in range(N-K+1):
    part += (P[K+i-1] - P[i])
    if res < part:
        res = part
        ind = i
ans = 0
for i in range(K):
    ans += calc(P[ind+i])
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
N, K = list(map(int, input().split()))
C = list(map(int, input().split()))
A=[]
for i in range(N):
  A.append((C[i]+1)/2)
B = [0] + A
B = list(accumulate(B))

ans = []
for i in range(N-K+1):
    ans.append(B[i+K]-B[i])

print(max(ans))
print(A)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
def f(n):
    return (n+1)/2
a=[]
for i in range(N-K+1):
    a.append(sum([f(p[j]) for j in range(i, i+K)]))
print(a)
print(max(a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(n-k+1):
    pre = List[i]
    for j in range(k-1):
        pre += List[i+j]
    

    if max < pre:
        index = i
        pre = 0
    else:
        pre = 0
    
#print(index)
for i in range(index, index+k):
    res += 1 + 0.5 * (List[i]-1)
    #print(List[i])

print(res)

Submission status: Wrong Answer

Solution code:
#At coder 2020/2/9 D

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=0.0
if N==K:
    kk=sum(p)
else:
    for ii in range(N-K):
        kk=max(kk,sum(p[ii:K+ii]))
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = [int(n) for n in input().split(" ")]
lst = [int(n) for n in input().split(" ")]

sum_max = 0
temp = 0

for i in range(K):
    temp += (lst[i]+1)/2
for j in range(0,N-K):
        temp += (lst[j+K]-lst[j])/2
        if temp > sum_max:
            sum_max = temp
            
print(sum_max)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = 0
Elist = []
for p in P[0:K]:
    plist = list(range(1, p+1))
    Elist.append(sum(plist) / len(plist))
E = sum(Elist)
oldE = E
count = K - 1
for p in P[K:]:
    count += 1
    plist = list(range(1, p+1))
    Elist.append(sum(plist) / len(plist))
    E -= Elist[count - K]
    E += Elist[count]
    if oldE <= E:
        print(E)
        oldE = E
print(oldE)

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    temp=0
    max=p[0]
    maxi=0
    temp=sum(p[0:k])
    if n>=2:
        for i in range(1,n-k+1):
            temp-=p[i-1]
            temp+=p[i+k-1]
            if temp>max:
                max=temp
                maxi=i
    total=(max+k)/2
#    for i in range(maxi,maxi+k):
 #       total+=(1+p[i])

    print(total)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, K = [int(n) for n in input().split(" ")]
lst = [int(n) for n in input().split(" ")]

sum_max = 0
temp = 0

for i in range(K):
    temp += (lst[i]+1)/2
for j in range(0,N-K):
        temp += (lst[j+K]-lst[j])/2
        print(temp)
        if temp > sum_max:
            sum_max = temp
            
print(sum_max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def culc_expected_value(num):
  output = 0
  if num != 1:
    for i in range(1, num+1):
      output += i/num
  else:
    output = 1
  return output
 
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_nums = 0
max_targets = []
for j in range(0, len(p_list)-k-1):
  targets = [p_list[j+m] for m in range(k)]
  t_sum = sum(targets)
  if t_sum >= max_nums:
    max_nums = t_sum
    max_targets = targets
# print(max_targets)

ans = 0
for t in max_targets:
  ans += culc_expected_value(t)
  # print(ans)

print(ans)

Submission status: Wrong Answer

Solution code:

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

p_shift = p[k:] + [0] * k

con_p = [0] * dices
sum_first_k = sum(p[0:k])

con_p[0] = sum_first_k

for i in range(dices-k-1):
    con_p[i+1] = con_p[i] + p_shift[i] - p[i]

max_expectation = (k + max(con_p))/2
print(max_expectation)

Submission status: Wrong Answer

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

list_ans = []

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

list_ans.sort



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

print(ans)

Submission status: Wrong Answer

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

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



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(k,n):
    if(p_n[i-k] < p_n[i]):
        sum_ex = sum_ex - p_n[i-k] + p_n[i]


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