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() ) )

sum_k = sum( p[ : k ] )
max_sum_k = 0

for i in range( k, n ):
    sum_k += p[ i ] - p[ i - k ]
    if sum_k > max_sum_k:
        print( i )
        max_sum_k = sum_k

print( ( max_sum_k + k ) / 2 )

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
c=list(map(int,input().split()))
a=[]
for x in range(n):
  s=c[x]
  t=(s+1)/2
  a.append(t)
  
ans=0
b=[]
b.append(a[0])

for y in range(n-1):
  c=b[y]
  d=b[y]+a[y+1]
  b.append(d)
  
dd=b[k-1]
for z in range(1,n+1-k):
  e=b[z+k-1]-b[z-1]
  
  dd=max(dd,e)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
c=list(map(int,input().split()))
a=[]
for x in range(n):
  s=c[x]
  t=(s+1)/2
  a.append(t)
  
ans=0
b=[]
b.append(a[0])

for y in range(n-1):
  c=b[y]
  d=b[y]+a[y+1]
  b.append(d)
  
dd=b[0]
for z in range(1,n+1-k):
  e=b[z+k-1]-b[z-1]
  dd=max(dd,e)
  
print(dd)

Submission status: Wrong Answer

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

S = []
pre = 0
for i in range(n):
    E = (p[i]+1.0) / 2.0
    E += pre
    S.append(E)
    pre = E
    
ans = 0
for j in range(n-k):
    now = S[j+k] - S[j]
    ans = max(ans, now)

print(ans)

Submission status: Wrong Answer

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

E = []
for i in range(n):
    e = (p[i]+1.0) / 2.0
    E.append(e)
    
ans = 0
for i in range(n-k):
    now = 0
    for j in range(k):
        now += E[i+j]
    ans = max(ans, now)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

l = [i for i in range(1, 1001)]
av = np.cumsum(l) / l

tmp = [av[i - 1] for i in p]
cs = list(np.cumsum(tmp))

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
maxI = 0
maxT = 0
t = 0
for i in range(n):
    t += p[i]
    if k <= i:
        t -= p[i-k]
    if maxT < t:
        maxT = t
        maxI = i
ans = 0


def calc(n):
    ans = 0
    for i in range(1, n+1):
        ans += i/n
    return ans


for i in range(maxI-k+1, maxI+1):
    print(i, p[i])
    ans += calc(p[i])
# print(p)
#print(maxT, maxI)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

values = [0]

for p in P:
    values.append(values[-1] + (p * (p + 1) // 2 / p))

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

print(ans)

Submission status: Wrong Answer

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

p = [int(x) for x in input().split()]

sum1 = sum(p[:k])
num = k-1

for i in range(k,n):
    before = sum1
    sum1 = sum1 - p[i-k] + p[i]
    if sum1 >= before:
        num = i

sum2 = sum(p[num-k+1:num+1])

def goukei(j):
    return 1/2 * j * (j+1)

print(float((goukei(sum2)-goukei(k-1))/(sum2 -k +1)))

Submission status: Wrong Answer

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

p = [int(x) for x in input().split()]

sum1 = sum(p[:k])
num = k-1

for i in range(k,n):
    temp = sum1 - p[i-k] + p[i]
    if temp >= sum1:
        num = i

#print(p[num])

sum2 = sum(p[num-k+1:num+1])

def goukei(j):
    return 1/2 * j * (j+1)

print((goukei(sum2)-goukei(k-1))/(sum2 -k +1))

Submission status: Wrong Answer

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

p = [int(x) for x in input().split()]

sum1 = sum(p[:k])
num = k-1

for i in range(k,n):
    temp = sum1 - p[i-k] + p[i]
    if temp >= sum1:
        num = i

print(p[num])

sum2 = sum(p[num-k+1:num+1])

def goukei(j):
    return 1/2 * j * (j+1)

print((goukei(sum2)-goukei(k-1))/(sum2 -k +1))

Submission status: Wrong Answer

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

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

sums = 0
ls =[]
#print(exp)
for n in range(N):
  sums += exp[n]
  ls.append(sums)

#print(ls)

ans = 0
for n in range(N-K):
  ans_candidate = ls[n+K]-ls[n]
  #print(ans_candidate)
  if ans < ans_candidate:
    ans = ans_candidate

print(ans)

Submission status: Wrong Answer

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

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

sums = 0
ls =[]

for n in range(N):
  sums += exp[n]
  ls.append(sums)



ans = 0
for n in range(N-K):
  ans_candidate = ls[n+K]-ls[n]
  
  if ans < ans_candidate:
    ans = ans_candidate

print(ans)

Submission status: Wrong Answer

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

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

ls =[]

for n in range(1,N+1):
  ls.append(sum(exp[:n]))



ans = 0
for n in range(N-K):
  ans_candidate = ls[n+K]-ls[n]
  
  if ans < ans_candidate:
    ans = ans_candidate

print(ans)

Submission status: Wrong Answer

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

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

ls =[]
print(exp)
for n in range(1,N+1):
  ls.append(sum(exp[:n]))



ans = 0
for n in range(N-K):
  ans_candidate = ls[n+K]-ls[n]
  
  if ans < ans_candidate:
    ans = ans_candidate

print(ans)

Submission status: Wrong Answer

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

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

ls =[]
print(exp)
for n in range(1,N+1):
  ls.append(sum(exp[:n]))
print(ls)


ans = 0
for n in range(N-K):
  ans_candidate = ls[n+K]-ls[n]
  
  if ans < ans_candidate:
    ans = ans_candidate

print(ans)

Submission status: Wrong Answer

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

S = [0]
sum_ = 0
for i, p in enumerate(P):
  sum_ += p
  S.append(sum_)


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

res = (max_sum + K) / 2

print(res)

Submission status: Wrong Answer

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

P = list(map(int, input().split()))
S = []

sum_ = 0
for i, p in enumerate(P):
  sum_ += p
  S.append(sum_)



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

res = (max_sum + K) / 2

print(res)

Submission status: Wrong Answer

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

P = list(map(int, input().split()))
S = [sum(P[:i+1]) for i in range(N)]

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

res = (max_sum + K) / 2

print(res)

Submission status: Wrong Answer

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

# 累積和
sum_ = 0
for p in P:
  sum_ += p
  S.append(sum_)

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

res = (max_sum + K)/ 2
print(res)

Submission status: Wrong Answer

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

max_sum = 0
sum_ = sum(P[:K])

for i, p in enumerate(P[:N-K+1]):
  max_sum = max(max_sum, sum_)
  sum_ -= p
  sum_ += P[i+K-1]

max_sum = max(max_sum, sum_)
          
res = (max_sum + K)/ 2
print(res)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    ans = 0
    for i in range(K,N):
        if K==N:print("{:.12f}".format(sum(P_ms)));exit(1)
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    ans = 0
    for i in range(K,N):
        if N==1:print("{:.12f}".format(P_ms[i]));exit(1)
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:f}".format(ans))
main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = []
for i in range(K):
   T = p[i:i+K]      
   ans.append(sum(T)/2+0.5*K)
ans = sorted(ans)
print(ans[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N,K=map(int, input().split())
P=np.array(list(map(int, input().split())))
 
P=(P+1)/2
ans=0
for i in range(N):
  try:
    ans=max(ans,sum(P[i:i+4]))
  except:
    break
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

P=(P+1)/2
ans=0
print(P)
for i in range(N):
  try:
    ans=max(ans,sum(P[i:i+4]))
  except:
    break
print(ans)

Submission status: Wrong Answer

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


l=[]
p=np.array(p)
for i in range(n):
  l.append(sum(p[i:i+k]))
  if sum(p[i:i+k])/k >= np.mean(p[i:]):
    break
  
ans=0.0
max=l.index(max(l))
ans=sum(list(range(1,p[max]+1)))/p[max]
x=sum(list(range(1,p[max]+1)))/p[max]
p0=p[max]
for i in range(max+1,max+k):
  g=p[i]-p[max]
  #print(p[max],p[i])
  ans+=x+(g*0.5)
  
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import accumulate

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = [(i+1)/2 for i in rl()]
a = list(accumulate(a))
ans = 0
for i in range(n-k):
    ans = max(ans, a[i+k] - a[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, k = rm()
a = rl()
max_ = 0
for i in range(n-k+1):
  max_ = max(max_, sum(a[i:i+k]))
print((max_+k)//2)

Submission status: Wrong Answer

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,k = MAP()

p = LIST()
#
# i=0
# j = k-1

mx = 0

for i in range(k):
    mx+=(p[i]+1)/2
    # print(mx)
gndMax = mx
i = 1
j=k
# print(mx)
while(j<n):
    gndMax=max(mx, mx+(p[j]+1)/2 - (p[i-1]+1)/2)
    mx = mx+(p[j]+1)/2 - (p[i-1]+1)/2
    i+=1
    j+=1
    # print(mx, gndMax)
print(gndMax)

Submission status: Wrong Answer

Solution code:

from itertools import accumulate
def resolve():
    def ev(x):
        return (x*(x+1)//2)/x

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

    E = [ev(a) for a in A]
    E = list(accumulate(E))
    ans = 0
    for i in range(N-K):
        if ans < E[i+K] - E[i]:
            ans = E[i + K] - E[i]
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    kitadic = {}
    kitadic[0] = kitalis[0] 
    for i in range(1, n):
        kitadic[i] = kitadic[i-1] + kitalis[i]
       
    tmp = 0
    for i in range(n - k):
        atai = kitadic[i+k] - kitadic[i]
        if tmp < atai:
            tmp = atai
    print(tmp)



    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    kitadic = {}
    for i in range(n):
        kitadic[i] = sum(kitalis[0:i+1])
       
    tmp = 0
    for i in range(n - k):
        atai = kitadic[i+k] - kitadic[i]
        if tmp < atai:
            tmp = atai
    print(tmp)



    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    saidai = max(inlis)

    tmp = 0
    for i in range(n - k + 1):
        if saidai in inlis[i:i+k]:
            if tmp < sum(inlis[i:i+k]):
                tmp = sum(inlis[i:i+k])
                tmplis = inlis[i:i+k]
    ans = sum(map(kitaichi, tmplis))
    print(ans)



    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

d = defaultdict(float)
for i in range(1, 1000):
    j = i
    while 0 < j:
        t = j * (1 / i)
        d[i] += t
        j -= 1

sum = [0.0]*(n+1)
for i in range(n):
    sum[i+1] = sum[i] + d[p[i]]

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

print('{:.12f}'.format(ans))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

d = defaultdict(float)
for i in range(1, 1000):
    j = i
    while 0 < j:
        t = j * (1 / i)
        d[i] += t
        j -= 1

sum = [0.0]*(n+1)
for i in range(n):
    sum[i+1] = sum[i] + d[p[i]]

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

print('{:6f}'.format(ans))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

d = defaultdict(float)
for i in range(1, 1000):
    j = i
    while 0 < j:
        t = j * (1 / i)
        d[i] += t
        j -= 1

ans = 0
for i in range(n-k+1):
    e = 0
    for j in range(k):
        e += d[p[i+j]]
    ans = max(ans, e)

print('{:6f}'.format(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [(p + 1) / 2 for p in P]
B = [0 for i in range(N)]
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
ans = 0
for i in range(K - 1, N):
    a = B[i] - B[i - K]
    if ans < a:
        ans = a
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
mmax=0
msum=0
maxI=0

for i in range(N-K):
  msum=0
  if p[i]>=p[i+K]:
    j=i
  else:
    j=i+1
  msum = sum(p[j:j+K])
  if msum>mmax:
    maxI=j
    mmax=msum

ans=(mmax+K)/2
print("{:.10f}".format(ans))

Submission status: Wrong Answer

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
mmax=0
msum=0
maxI=0

for i in range(N-K):
  msum=0
  if p[i]>=p[i+K]:
    msum = sum(p[i:i+K])
    if msum>mmax:
      maxI=i
      mmax=msum
  else:
    msum = sum(p[i+1:i+K+1])
    if msum>mmax:
      maxI=i+1
      mmax=msum
ans=(mmax+K)/2
print("{:.10f}".format(ans))

Submission status: Wrong Answer

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
max=0
sum=0
maxI=0

for i in range(N-K):
  sum=0
  if p[i]>=p[i+K]:
    for j in range(i,i+K):
      sum+=p[j]
    #print("sum=:"+str(sum)+"max=:"+str(max))
    if sum>max:
      maxI=i
      max=sum
    #print("maxI=:"+str(maxI)+"max=:"+str(max))
  else:
    for j in range(i+1,i+K+1):
      sum+=p[j]
    #print("sum=:"+str(sum)+"max=:"+str(max))
    if sum>max:
      maxI=i+1
      max=sum
    #print("maxI=:"+str(maxI)+"max=:"+str(max))

ans=0
#print(maxI)
#for i in range(maxI,maxI+K):
  #sum=0
  #for j in range(1,p[i]+1):
  #  sum+=j
  #sum/=p[i]
  #ans+=(i+1)/2
ans=(max+K)/2
print("{:.7f}".format(ans))

Submission status: Wrong Answer

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
max=0
sum=0
maxI=0

for i in range(N-K):
  if p[i]>=p[i+K]:
    for j in range(i,i+K):
      sum+=p[j]
    if sum>max:
      maxI=i
  else:
    for j in range(i+1,i+K+1):
      sum+=p[j]
    if sum>max:
      maxI=i+1

ans=0
for i in range(maxI,maxI+K):
  sum=0
  for j in range(1,p[i]+1):
    sum+=j
  sum/=p[i]
  ans+=sum
print("{:.7f}".format(ans))

Submission status: Wrong Answer

Solution code:
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
max=0
sum=0
maxI=0

for i in range(N-K):
  if p[i]>=p[i+K]:
    for j in range(i,i+K):
      sum+=p[j]
    if sum>max:
      maxI=i
  else:
    for j in range(i+1,i+K+1):
      sum+=p[j]
    if sum>max:
      maxI=i+1

ans=0
for i in range(maxI,maxI+K):
  sum=0
  for j in range(1,p[i]+1):
    sum+=j
  sum/=p[i]
  ans+=sum
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
pList = list(map(int, input().split()))
#範囲内の和を求めるには累積和とういうのを使う
#事前準備
cum_sum_list = [0]*(N+1)
cum_sum = 0
pListLen = len(pList)
for i in range(pListLen):
  cum_sum += pList[i]
  cum_sum_list[i] = cum_sum
#範囲内の和を比べていく
max_sumK = 0
max_start = 0
max_end = 0
for i in range(N-K+1):
  start = i
  end = (i+K)
  sumK = cum_sum_list[end] - cum_sum_list[start]
  if (sumK > max_sumK):
    max_sumK = sumK
    max_start = start
    max_end = end
#最大の期待値を計算して出力
answer = 0
for num in pList[max_start:(max_end+1)]:
  answer += sum(list(range(1, (num+1))))/num
print(answer)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
pList = list(map(int, input().split()))
#範囲内の和を求めるには累積和とういうのを使う
#事前準備
cum_sum_list = [0]*N
cum_sum = 0
pListLen = len(pList)
for i in range(pListLen):
  cum_sum += pList[i]
  cum_sum_list[i] = cum_sum
#範囲内の和を比べていく
max_sumK = 0
max_start = 0
max_end = 0
for i in range(N-K+1):
  start = i
  end = (i+K)-1
  sumK = cum_sum_list[end] - cum_sum_list[start]
  if (sumK > max_sumK):
    max_sumK = sumK
    max_start = start
    max_end = end
#最大の期待値を計算して出力
answer = 0
for num in pList[max_start:(max_end+1)]:
  answer += sum(list(range(1, (num+1))))/num
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  N, K = map(int, input().split())
  p = list(map(int, input().split()))
  
  l = sorted(p, reverse=True)   #降順
  #print(l)
  
  #for i in range(K, N):
  del l[K:]
  #print(l)
    
  ans = 0
    
  for i in l:
    ans += float(sum(range(1, i+1)) / i)
    
  print(ans)
 
  
  
main()

Submission status: Wrong Answer

Solution code:
def main():
  N, K = map(int, input().split())
  p = list(map(int, input().split()))
  
  l = sorted(p, reverse=True)   #降順
  #print(l)
  
  #for i in range(K, N):
  del l[K:]
  #print(l)
    
  ans = 0
    
  for i in l:
    ans += sum(range(1, i+1)) / i
    
  print(ans)
 
  
  
main()

Submission status: Wrong Answer

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

c=sum(b[:k])
for i in range(n-k):
    c-=b[i]
    c+=b[k+i]
    m=max(m,c)
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy
n, k= map(int,input().split())
ps = list(map(int, input().split()))
    
# 数値を倍にする関数
def calc_double(n):
    return (n +1)/2
 
data2 = list(map(calc_double, ps))
res = numpy.cumsum(data2)
tmp=0
for i in range(len(res)-k):
    tmp=max(tmp, res[i+k] - res[i])

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

Submission status: Wrong Answer

Solution code:
import numpy
n, k= map(int,input().split())
ps = list(map(int, input().split()))
# 数値を倍にする関数
def calc_double(n):
    return (n +1)/2
 
data2 = list(map(calc_double, ps))
res = numpy.cumsum(data2)
tmp=0
for i in range(len(res)-k):
    if res[i+k]-res[i] >=tmp:
        tmp=res[i+k]-res[i]

print(tmp)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-06-26 21:21:26 +0900
# LastModified: 2020-06-26 21:42:12 +0900
#


import os
import sys
from itertools import accumulate
# import numpy as np
# import pandas as pd


def main():
    n, k = map(int, input().split())
    p = list(accumulate(list(map(int, input().split()))))
#    print(p)
    e_max = 0
    for i in range(n-k):
#        print(p[i], p[i+k])
        if p[i+k]-p[i] > e_max:
            e_max = p[i+k]-p[i]
    print((e_max+k)/2)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = list(map(int,input().split()))
ele = K-1
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N):
    if a[i-K]<a[i]:
        ele = i
s_ele = ele-(K-1)
for n in range(s_ele,ele+1):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def expectation(N):
    exp = 0
    for i in range(1, N+1):
        exp += i/N
    return exp

cmax = sum(P[:K])
max_sp = 0

for ix in range(1, N-K):
    csum = sum(P[ix:ix+K])
    # print(ix, csum, "{}-{}".format(ix, ix+K))
    if cmax < csum:
        max_sp = ix
        cmax = csum

# print(max_sp)
# print(cmax)
ans = 0
for ix in range(max_sp, max_sp+K):
    ans += expectation(P[ix])

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
Ruiseki = 0
S = []
Top = 0
for i in p:
    q.append((i+1) / 2)

for E in q:
    Ruiseki += E
    S.append(Ruiseki)

for j in range(N-K):
    Sig = S[K+j] - S[j]
    if Sig > Top:
        Top = Sig

print(Top)

Submission status: Wrong Answer

Solution code:
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
Ruiseki = 0
S = []
Top = 0
for i in p:
    q.append((i+1) / 2)

for E in q:
    Ruiseki += E
    S.append(Ruiseki)

for j in range(N-K+1):
    Sig = S[K+j-1] - S[j-1]
    if Sig > Top:
        Top = Sig

print(Top)

Submission status: Wrong Answer

Solution code:
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
for j in p:
    q.append((j+1) / 2)

print(q)

for i in range(N-K+1):
    E = 0
    for n in range(K):
        E += q[n+i]
    if E > Etop:
        Etop = E
print(Etop)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from decimal import Decimal
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[]
tmp=0
for i in range(n):
    p[i]=Decimal((p[i]+1)/2)
    tmp+=p[i]
    l.append(tmp)
ans=0
for i in range(k,n):
    tmp=l[i]-l[i-k]
    if tmp>ans:
        ans=tmp
print(Decimal(ans))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from decimal import Decimal
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[]
tmp=0
for i in range(n):
    p[i]=(p[i]+1)/2
    tmp+=p[i]
    l.append(tmp)
ans=0
for i in range(k,n):
    tmp=l[i]-l[i-k]
    if tmp>ans:
        ans=tmp
print(Decimal(ans))

Submission status: Wrong Answer

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