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()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = sum(P[0:K])
for i in range(K, N):
    total = tmp-P[i-K]+P[i]
    if tmp < total:
        index = i-K+1
        tmp = total
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a = input("整数を入力:")
N,K = a.split()
b = input("ダイスの目:")
pl = b.split()

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 1
        j = 0
        kitaiti = 0
        kari = 0
        if int(p) > 1000:
            print("1000以下を入れろｋｓ")
            break
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print("{:.12f}".format(kitaiti))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=1)

ans = sum(A[:k])+k
ans /= 2
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=1)

print((sum(A[:k])+k)/2)

Submission status: Wrong Answer

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

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

ans = S[0]
for i in range(N-K):
  diff = S[i+K] - S[i]
  ans = max(ans, diff)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a = input("整数を入力:")
N,K = a.split()
b = input("ダイスの目:")
pl = b.split()

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 1
        j = 0
        kitaiti = 0
        kari = 0
        if int(p) > 1000:
            print("1000以下を入れろｋｓ")
            break
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print(kitaiti)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a = input("整数を入力:")
N,K = a.split()
b = input("ダイスの目:")
pl = b.split()
print(pl)

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 1
        j = 0
        kitaiti = 0
        kari = 0
        if int(p) > 1000:
            print("1000以下を入れろｋｓ")
            break
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    print(pk)
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print(kitaiti)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n,k=map(int,input().split())
p=[ int(i) for i in input().split() ]
kitaichi_kouho=sum(p[:k])
kitaichi_list = kitaichi_kouho
max_sum=0

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

print((k+max_sum)/2)

"""
5 3
1 2 2 4 5
ans >> 7.0

10 4
17 13 13 12 15 20 10 13 17 11
ans >> 32.0
"""

Submission status: Wrong Answer

Solution code:
n,k,*p=map(int,open(0).read().split())
s=m=sum(p[:k])
for i in range(k,n):s+=p[i]-p[i-k];m=max(m,s)  
print((s+k)/2)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a = input("整数を入力:")
N,K = a.split()
b = input("ダイスの目:")
pl = b.split()
print(pl)

pk = []

if 1 <= int(K) and int(K) <= int(N) and int(N) <= 200000 and len(pl) == int(N):
    for p in pl:
        i = 1
        j = 0
        kitaiti = 0
        kari = 0
        if int(p) > 1000:
            print("1000以下を入れろｋｓ")
            break
        for i in range(1,int(p)+1):
            j += i
        pk.append(j/int(p))
    print(pk)
    for z in range(len(pk)+1):
        jougen = len(pk)-z
        if int(K) <= jougen:
            kari = 0
            maxrange = int(z)+int(K)
            for x in range(int(z),maxrange):
                kari += pk[int(x)]
        if kitaiti < kari:
            kitaiti = kari
print("期待値"+ str(kitaiti))

Submission status: Wrong Answer

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

dicesSum=[]
l1=ps[0:K]
dicesSum.append(sum(l1))

if K==N:
    exp= (K+ dicesSum[0])/2
    print(exp)
else:
    for i in range(1,N-K+1):
        dicesSum.append(dicesSum[i-1]-ps[i-1]+ps[i+K-1])
    print(dicesSum)
    max_value = max(dicesSum)
    exp= (K+ max_value)/2
    print(exp)

Submission status: Wrong Answer

Solution code:
N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
S = [sum(P[:i+1]) for i in range(N)]

m = 0 
for i in range(N-K):
  if m < S[i+K]-S[i]:
    m= S[i+K]-S[i]
print(m)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    l = list(map(lambda x: x * (x + 1) * 1 / 2 * 1 / x, p))

    m = sum(l[:k])
    ans = m
    for i in range(n - k):
        m = m + l[k+i] - l[i]
        if m == max(ans, m):
            ans = m

    print(m)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

dicesSum=[]
l1=ps[0:K]
dicesSum.append(sum(l1))

if K==1:
    exp= (1+ dicesSum[0])/2
    print(exp)
else:
    for i in range(1,N-K):
        dicesSum.append(dicesSum[i-1]-ps[i-1]+ps[i+K-1])
    max_value = max(dicesSum)
    exp= (K+ max_value)/2
    print(exp)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    resolve()

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 N == M:
        return (1 + l[N-1]) / 2

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

    return ans

print(solve())

Submission status: Wrong Answer

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

ans = 0
data = np.sum(x[:K])

for i in range(N-K):
	data = data + x[i+K] - x[i]
	if data > ans:
		ans = data

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()] #期待値にして格納

#累積和を求める
for i in range(1,n):
    p[i]=p[i-1]+p[i]
mx = p[0]
for i in range(k,n):
    a = p[i] - p[i-k]
    print(a)
    if a > mx:
        mx = a
        
print(mx)

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
if N == 1:
  print(result[0])
  exit()
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 = map(int, input().split())
list=list(map(int, input().split()))
m=0
for i in range(N+K-1):
    m=max(m, sum(list[i:i+K-1]))
    if m == sum(list[i:i+K-1]):
        n = i
a=list[n:n+K]
print(a)
su=0
for i in a:
    su+=(i*(1/2)+1)
print(su)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, k  = MAP()
p = LIST()

def kitai(a):
    tmp = 0
    # for a in A:
    tmp = 1/a * (1/2 * a * (a+1))
    return tmp
acc = [0] * n

# それぞれの期待値を先に求めて，それから和を求める
for i in range(n):
    acc[i] = (p[i] + 1) / 2
ruiseki = [0] * n
ruiseki[0] = acc[i]
for i in range(n-1):
    ruiseki[i+1] = ruiseki[i] + acc[i+1]
# print(acc)
# print(ruiseki)
# acc = list(accumulate([0]+acc))
ans = 0

ruiseki.insert(0, 0)
ans = 0
for i in range(n-k+1):
    m = ruiseki[k+i] - ruiseki[i]
    ans = max(ans, m)
print(ans)

    
    # if i == 0:
    #     ruiseki[k]
    # else:
    #     ruiseki[k+i] - ruiseki[i]
    # ans = max(ans, acc[i+k]-acc[i])

Submission status: Wrong Answer

Solution code:
num=list(map(int,input().split()))
nums=list(map(int, input().split()))
a=[0,0,0,0]
max=-1
for i in nums:
    a.append((i+1)/2)
    a.pop(0)
    s=sum(a)
    if(s>max):
        max=s
print(max)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()] #期待値にして格納

#累積和を求める
for i in range(1,n):
    p[i]=p[i-1]+p[i]
mx = 0
for i in range(k,n):
    a = p[i] - p[i-k]
    if a > mx:
        mx = a
print(mx)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
 
an=0
an2=0
t=0
 
for i in range(n):
    if i<k:
        an+=((p[i]+1)/2)
        an2=an
    else:
        t=((p[i-k]+1)/2)
        if an+((p[i]+1)/2)-t>an:
            an2=an+((p[i]+1)/2)-t
        an=an+((p[i]+1)/2)-t
            
print(an2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
 
an=0
an2=0
an3=0
t=0
 
if k==1:
    print(int(max(p))*0.5+0.5)
    exit()
 
for i in range(n):
    if i<k:
        an+=p[i]
        an2=an
    else:
        t=p[i-k]
        if an+p[i]-t>an:
            an2=an+p[i]-t
            flug=(i-k)
        an=an+p[i]-t
            
print((an2*0.5)+(k*0.5))

Submission status: Wrong Answer

Solution code:
def main():
  from itertools import accumulate
  import sys
  read = sys.stdin.buffer.read
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(y - x for x, y in zip(p, p[K:])) + K) / 2)

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
p = list(map(int,input().split()))
n = a[0]
k = a[1]

E = [0]*(n+1)

sum_E = 0
max_E = 0

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

for i in range(n-k):
  if max_E < E[i+k] - E[i]:
    max_E = E[i+k] - E[i]
#print(E)
print(max_E)

Submission status: Wrong Answer

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

def expect( n: int ):
  return sum( range( n + 1 ) ) / n

pl = list( map( expect, p ) )

now_val = 0
for i in range( k ):
  now_val += pl[ i ]

maxs = 0
for i in range( 1, n - k + 1 ):
  now_val = now_val - pl[ i - 1 ]  + pl[ i + k - 1 ]
  maxs = max( maxs, now_val )
print( maxs )

Submission status: Wrong Answer

Solution code:
N,K = input().split() # times of throwing　P1,P2...,Pn
N = int(N)
K = int(K)
p = list(input().split())
p_int = []

for j in range(len(p)):
    p_int.append(int(p[j]))

# print(p_int)

Pattern = N - K + 1
expect = []
sum_expect = []
s = 0
x = 0
for i in range(N):

    for x in range(p_int[i]):
        s += p_int[i]-x
        print(s)


    e = float('{0:.5f}'.format(s / p_int[i]))
    expect.append(e)
    x = 0
    s = 0

# print(expect)
amount = 0
count = 0
for i in range(Pattern):

    for count in range(K):
        amount += expect[count + i]

    sum_expect.append(amount)
    amount = 0

# print(sum_expect)
print(max(sum_expect))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys 

N, K = [int(x) for x in sys.stdin.readline().strip().split(" ")]
p = [int(x) for x in sys.stdin.readline().strip().split(" ")]

def ev(v):
    return sum(range(1,v+1)) * 1.0/v

m = 0 
i = 0 
while i+2 < N:
    v = ev(p[i]) + ev(p[i+1]) + ev(p[i+2])
    if m < v:
        m = v 
    i += 1

print(m)

Submission status: Wrong Answer

Solution code:
N,K = input().split() # times of throwing　P1,P2...,Pn
N = int(N)
K = int(K)
p = list(input().split())
p_int = []

for j in range(len(p)):
    p_int.append(int(p[j]))

# print(p_int)

Pattern = N - K + 1
expect = []
sum_expect = []
s = 0
x = 0
for i in range(N):

    for x in range(p_int[i]):
        s += p_int[i]-x
        print(s)


    e = float('{0:.5f}'.format(s / p_int[i]))
    expect.append(e)
    x = 0
    s = 0

print(expect)
amount = 0
count = 0
for i in range(Pattern):

    for count in range(K):
        amount += expect[count + i]

    sum_expect.append(amount)
    amount = 0

print(sum_expect)
print(max(sum_expect))

Submission status: Wrong Answer

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

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K+1):
    summ = summ - P[i] + P[K+i-1]
    if summ > maxi:
        maxi = summ
        idx = i
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))

Submission status: Wrong Answer

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

ans = sum(sum_p[0:k])
for i in range(k,n):
    if ans + sum_p[i] - sum_p[i - k] > ans:
        ans = ans + sum_p[i] - sum_p[i - k]

print(ans)

Submission status: Wrong Answer

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

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

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

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())
p = list(map(int,input().split()))

ex_list = list() 
for i in range(len(p)):
	if i != 0:
		ex_list.append(((1+p[i])/2)+ex_list[-1])
	else:
		ex_list.append((1+p[i])/2)
ans = ex_list[K-2]
for i in range(N-K):
	ex = abs(ex_list[i] - ex_list[i+K])
	if ans < ex:
		ans = ex
print(ans)

Submission status: Wrong Answer

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

# 期待値の累積和リストを生成
ex_list = list() 
for i in range(len(p)):
	if i != 0:
		ex_list.append(((1+p[i])/2)+ex_list[-1])
	else:
		ex_list.append((1+p[i])/2)
print(ex_list)
ans = ex_list[K-2]
for i in range(N-K):
	print(i,ex_list[i],ex_list[i+K])
	ex = abs(ex_list[i] - ex_list[i+K])
	if ans < ex:
		ans = ex
print(ans)

Submission status: Wrong Answer

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

def expect( n: int ):
  return sum( range( n + 1 ) ) / n

now_val = 0
for i in range( k ):
  now_val += expect( p[ i ] )

maxs = 0
for i in range( 1, n - k + 1 ):
  now_val = now_val - expect( p[ i - 1 ] )  + expect( p[ i + k - 1 ] )
  maxs = max( maxs, now_val )
print( maxs )

Submission status: Wrong Answer

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

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
if N==K:
  print(max_e)
else:
  for i in range(0,N-K-1):
    e=s[i+K]-s[i]
    #print(e)
    e=(K+e)/2
    #print(e)
    max_e = max(max_e, e)

  print(max_e)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
p = list(map(int,input().split()))
n = a[0]
k = a[1]

E = [0]*n
sum_E = 0
max_E = 0

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

for i in range(n-k):
  if max_E < E[i+k] - E[i]:
    max_E = E[i+k] - E[i]

print(max_E)

Submission status: Wrong Answer

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

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
if N==1:
  print(max_e)
else:
  for i in range(0,N-K-1):
    e=s[i+K]-s[i]
    #print(e)
    e=(K+e)/2
    #print(e)
    max_e = max(max_e, e)

  print(max_e)

Submission status: Wrong Answer

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

    summ = sum(P[0:K])
    maxi = summ
    idx = 0
    ans = []
    for i in range(N-K):
        summ = summ + P[i] - P[K+i]
        if summ > maxi:
            maxi = summ
            idx = i
    for j in range(K):
        ans.append((P[idx+j]+1)/2)
    print(sum(ans))
main()

Submission status: Wrong Answer

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

# 期待値の累積和リストを生成
ex_list = list() 
for i in range(len(p)):
	if i != 0:
		ex_list.append(((1+p[i])/2)+ex_list[-1])
	else:
		ex_list.append((1+p[i])/2)
ans = 0
for i in range(N-K):
	ex = abs(ex_list[i] - ex_list[i+K])
	if ans < ex:
		ans = ex
print(ans)

Submission status: Wrong Answer

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

max_e = 0

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

print((max_e + 3) / 2)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, K = map(int, input().split())
E = list(map(lambda x: (int(x) + 1) / 2, input().split()))
res = np.cumsum(E)

ans = 0
for i in range(N - K):
    a = res[N - i - 1] - res[N - i - K - 1]
    if ans < a:
        ans = a
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = input().split()
bubun = [0 for i in range(N)]
sums= [0 for i in range(N+K)]
E=0
S=0

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


sums[0] = p[0]
for i in range(N-1):
    sums[i+1] = sums[i] + p[i+1]

for i in range(N):
    if i == 0:
        bubun[i] = sums[K]
    else:
        bubun[i] = sums[i+K-1]-sums[i-1]

for i in range(N):

    if bubun[i] > S:
        S = bubun[i]


E=(S+K)/2

print(E)

Submission status: Wrong Answer

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

#p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=(K+e)/2
for i in range(0,N-K-1):
  e=s[i+K]-s[i]
  #print(e)
  e=(K+e)/2
  #print(e)
  max_e = max(max_e, e)
    
print(max_e)

Submission status: Wrong Answer

Solution code:
def calc_ex(x):
  p = 1 / x
  # ex = 0

  ex_list = list(range(x))
  ex_list = list(map(lambda s: (s + 1) * p, ex_list))


  # for i in range(x + 1):
  #   px = p * i
  #   ex += px

  return sum(ex_list)

ans = 0
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
p_ex = list(map(calc_ex, p))
res = [0] + p_ex
# print(p_ex)
# print(res)

for i in range(len(p_ex)):
  res[i+1] = res[i] + p_ex[i]

del res[0]


for i in range(len(res) - k):
  new = res[i + k] - res[i]
  if new > ans:
    ans = new

print(ans)

Submission status: Wrong Answer

Solution code:
def calc_ex(x):
  ex = (1 + x) / 2
  return ex

ans = 0

n, k = map(int, input().split())
p = [int(i) for i in input().split()]
p_ex = list(map(calc_ex, p))
res = [0] + p_ex
# print(p_ex)
# print(res)

for i in range(len(p_ex)):
  res[i+1] = res[i] + p_ex[i]

del res[0]


for i in range(len(res) - k):
  new = res[i + k] - res[i]
  if new > ans:
    ans = new

print(ans)

Submission status: Wrong Answer

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

s = sum(p_n[0:k])
max_s = 0

for i in range(n - k):
    s = p_n[i + k] + s - p_n[i]

    if s > max_s:
        max_s = s

print((max_s + k) / 2)

Submission status: Wrong Answer

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

s = sum(p_n[0:k])
max_s = 0

for i in range(n - k):
    s = p_n[i + k] + s - p_n[i]
    print(s)

    if s > max_s:
        max_s = s

print((max_s + k) / 2)

Submission status: Wrong Answer

Solution code:
import numpy


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] = (1 + P[i]) / 2
        if sum(max_tmp) < sum(tmp):
            max_tmp = tmp
            start_index = i

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

    ans = numpy.cumsum(ans[start_index: start_index + K])

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
list=list(map(int, input().split()))
m=0
for i in range(N+K-1):
    m=max(m, sum(list[i:i+K]))
    if m == sum(list[i:i+K]):
        n = i
a=list[n:n+K]
su=0

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    N, K, *p = map(int, read().split())
    p = list(map(lambda x: (x+1)*0.5, p))
    p_sum = [p[i-1] + p[i] if i != 0 else p[i] for i in range(len(p))]
    result = 0
    for i in range(N-K):
        result = max(result,p_sum[K-1+i] -p_sum[i])
    return result

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

Submission status: Wrong Answer

Solution code:
def main():
  def CalExVal(x):
    return (1/2*(x+1))
  N, K = map(int, input().split())
  A = list(map(int, input().split()))


  Ex = list((map(CalExVal, A)))
  #temp = len(A)-K + 1
  #adjlist = [0]*(temp)
  #adjlist = [sum(list(map(CalExVal, A))[i:(K+i)]) for i in range(temp)]
  tem = sum(Ex[:K])
  res = tem
  for i in range(0,N-K):
      adj = tem - Ex[i] + Ex[i+K]
      if res < adj:
      	res = adj
  print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 期待値
E = [(p+1)/2 for p in P]

# 累積和
S = [0] * N
S[0] = E[0]
for i in range(1, N):
    S[i] = S[i-1] + E[i]

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K):
    tmp_E = S[i+K] - S[i]
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

Submission status: Wrong Answer

Solution code:
raw = input()
N, K = raw.split(' ')
N = int(N)
K = int(K)
str_li = input().split(' ')
num_li = list(map(int, str_li))
sum_li = [0]
for i in num_li:
    sum_li.append(sum_li[-1] + i + 1)

ans = 0
for index in range(K, N):
    ans_tmp = sum_li[index] - sum_li[index - K]
    if ans_tmp > ans:
        ans = ans_tmp
print(ans/2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from operator import add
import copy

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


E = [0] * (N+1)
S = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
  E[i] = (1+p[i])/2
  S[i+1] = S[i] + E[i]
  if K<i+2:
    R[i] = S[i]-S[i-K]



print("{:.12f}".format(max(R)))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline

    N, K = map(int, input().split())
    P = np.array(list(map(float, input().split())))
    p_cumsum = np.cumsum(P)

    ans = 0
    for i in range(len(p_cumsum)-K):
        ans = max(ans, p_cumsum[i+K]-p_cumsum[i])
    ans = (K + ans) * 0.5

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
val2 = 0
for i in range(k):
    val2 += p[i]
#print(val2)
val = val2
for i in range(k,n):
    if val < val2:
        val = val2
        atai = i-k+1
    #print(i,p[i],p[i-k])
    val2 += p[i]
    if i==k:
        val2 == 0
    else:
        val2 -= p[i-k-1]
    #print(val2)
    if val < val2:
        val = val2

        atai = i-k+1

#print(atai)
ans = 0
for i in range(k):
    kitai = 0
    for j in range(1,p[atai]+1):
        kitai += j
    ans += kitai / p[atai]
    atai += 1
    #print(atai)
    #print(kitai)
print(ans)

Submission status: Wrong Answer

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

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

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

print(value)

Submission status: Wrong Answer

Solution code:
#模範解答の通りにやってみる
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
if K==1:
	print((max(P)+1)/2)
elif N==K:
	print((sum(P)+N)/2)
else:
	for k in range(1,N+1):
		S.append(sum(P[0:k]))
	print(S)
	T=[S[K-1]]
	for n in range(0,N-K):
		T.append(S[n+K]-S[n])
	print(T)
	print((max(T)+K)/2)

Submission status: Wrong Answer

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

def kitai(x):
  return (1+int(x))/2

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

pre = psum = sum(p[0:k])

for i in range(n):
  if i+k > n:
    break
  pre = pre - p[i-1] + p[i+k-1]
  psum = max(psum, pre)

print(psum)

Submission status: Wrong Answer

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

s=[(p[n]+1)/2 for n in range(N)]
S=[0]*N
S[0]=s[0]

for n in range(N-1):
    S[n+1]=s[n+1]+S[n]
def sjk(j):
    return S[j+K]-S[j]
delta = [sjk(i) for i in range(N-K)]
M=0
for i in range(N-K):
    if M<sjk(i):
        M=sjk(i)
print(M)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
lis_p = map(int, input().split())
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp=0
cumKsum = sum(lis_exp[0:K])
for i in range(1, N-K+1):
    cumKsum = cumKsum - lis_exp[i-1] + lis_exp[i+K-1]
    dp = max(cumKsum, dp)
print(dp)