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=input().split()
n,k=int(N),int(K)
p=list(input().split())
ans = 0

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

pre=[0 for i in range (n+1)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

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

print ((ans + k) / 2)

Submission status: Wrong Answer

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

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

pre=[0 for i in range (n+1)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

for i in range(1,n-k+1):
    q[i]=pre[i+k]-pre[i]
   
ans=max(q)

print ((ans + k) / 2)

Submission status: Wrong Answer

Solution code:
n , k = input().split()
n = int(n)
k = int(k)
p = input().split()
pre = []
sum1 = 0
ans = 0

for i in range (n) :
    sum1 += int(p[i]) + 1
    pre.append(sum1)

for i in range (n - k) :
    avg = pre[i + k] - pre[i]
    ans = max(ans , avg)

print (ans / 2)

Submission status: Wrong Answer

Solution code:
n , k = input().split()
n = int(n)
k = int(k)
p = input().split()
pre = []
sum1 = 0
ans = 0

for i in range (n) :
    sum1 += int(p[i]) + 1
    pre.append(sum1)
print (pre)

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

print (ans / 2)

Submission status: Wrong Answer

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

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

maxs=0


def f(m,p):
    q=0
    for i in range (m):
        q=q+p[i]
    return q
    

for i in range (n-k):
    a=f(i+k,p)-f(i,p)
    if a>=maxs:
        maxs=a
print (maxs)
print((maxs+k)/2)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
num = list(map(int, input().split()))
import numpy
res = numpy.cumsum(num)
maxRange = -1
for i in range(n-k+1):
  r = res[i+k-1] - res[i]
  if maxRange < r:
    maxRange = max(r, maxRange)
    p, q = i, i+k-1
ans = 0
for j in range(p, q+1):
  ans += (num[j]+1)/2
print(ans)

Submission status: Wrong Answer

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

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

B = []
t = -1
init_sum = sum(A[0:k])

for i in range(n - k+1):
    if t < init_sum:
        B = A[i:i+k]
        t = init_sum
    if i != n - k:
        init_sum = init_sum - A[i] + A[i+k]


import collections
B = sorted(B)
C = collections.Counter(B)

D = list(C.keys())
E = []
j = 0
total = 0
for i in range(max(list(C.keys())) + 1):
    total += i
    if D[j] == i:
        E.append(total)
        j += 1
ans = 0
for i, j in zip(D, E):
    ans += (j / i) * C[i]
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
n=s.split()
s=input()
p=s.split()
a=[]
a.append(int(p[0]))
now=a[0]
for i in range(1,int(n[0])):
	now+=int(p[i])
	a.append(now)
print(a)
k=int(n[1])
m=a[k-1]
for i in range(k,int(n[0])):
	if m<a[i]-a[i-k] :
		m=a[i]-a[i-k]
print('{:.8f}'.format(m/2+k/2))

Submission status: Wrong Answer

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


def calc_kitaiti(n):
    sum_n = 0
    if n % 2 == 0:
        temp = n / 2
        sum_n = (temp * n) + temp
    else:
        temp = (n - 1) / 2
        sum_n = (n * (temp + 1))

    return sum_n / n


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    kitaitis = []
    pre = 0
    for _a in a:
        pre += calc_kitaiti(_a)
        kitaitis.append(pre)

    result = 0
    for i in range(k - 1, n):
        start = i - k
        result = max(result, kitaitis[i] - kitaitis[start])

    return result


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

Submission status: Wrong Answer

Solution code:
import queue
N,K=map(int,input().split())
P=list(map(int,input().split()))
que=queue.Queue()
que_tmp=queue.Queue()
ans=0
tmp=0
cnt=0
for p in P:
    if cnt<K:
        que_tmp.put(1+p)
        tmp+=1+p
        cnt+=1
    else:
        que.put(1+p)

while not que.empty():
    dis=que_tmp.get()
    plus=que.get()
    que_tmp.put(plus)
    tmp+=plus-dis
    ans=max(ans,tmp)
print(ans/2)

Submission status: Wrong Answer

Solution code:
import queue
N,K=map(int,input().split())
P=list(map(int,input().split()))
que=queue.Queue()
que_tmp=queue.Queue()
ans=0
tmp=0
cnt=0
for p in P:
    if cnt<K:
        que_tmp.put((1+p)/2)
        tmp+=(1+p)/2
        cnt+=1
    else:
        que.put((1+p)/2)

while not que.empty():
    dis=que_tmp.get()
    plus=que.get()
    que_tmp.put(plus)
    tmp+=plus-dis
    ans=max(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = 0
A = []
B = 0
for i in range(len(p)-K+1):
    P = p[i:i+3]
    if ans < sum(P):
        ans2 = P
    ans = max(ans,sum(P))
for j in range(len(P)):
    for k in range(1,P[j]+1):
        A.append(k)
    B += sum(A)/P[j]
    A.clear()
print(B)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
def expected_value(li):
    def _expect(i):
        return (i+1) * (i / 2) / i
    return sum(map(_expect, li))

ans = 0

for x in range(N - K + 1):
    r = expected_value(p[x:x+3])
    if r > ans:
        ans = r
        
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

def ev(n):
    return (n+1)/2

A = [ev(i) for i in A]

if N == K:
    print(sum(A))

i = 0
total = sum(A[0:K])
mx = total

#N = 4
#K = 3


while i < N - K:
    total += A[i+K] - A[i]
    mx = max(mx, total)
    i += 1

print(mx)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
 
def ev(n):
    return (n+1)/2
 
from collections import deque
 
if K == N:
    print(sum(ev(a) for a in A))
 
deq = deque()
 
while len(deq) < K:
    deq.append(ev(A.pop()))
 
total = sum(i for i in deq)
mx = total
 
while A:
    out = deq.popleft()
    in_ = ev(A.pop())
    deq.append(in_)
    
    total -= out
    total += in_
    mx = max(mx, total)
 
print(mx)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

def ev(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1.5
    else:
        return (n+1)/2

from collections import deque

if K == N:
    print(sum(ev(a) for a in A))

deq = deque()

while len(deq) < K:
    deq.append(ev(A.pop()))

total = sum(i for i in deq)
mx = total

while A:
    out = deq.popleft()
    in_ = ev(A.pop())
    deq.append(in_)
    
    total -= out
    total += in_
    mx = max(mx, total)

print(mx)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

def ev(n):
    if n == 1:
        return 1
    elif n == 2:
        return 1.5
    else:
        return (n+1)/2

from collections import deque

if K == N:
    print(sum(ev(a) for a in A))

deq = deque()

while len(deq) < K:
    deq.append(ev(A.pop()))

total = sum(i for i in deq)
mx = total

while A:
    out = deq.popleft()
    in_ = ev(A.pop())
    deq.append(in_)
    
    total -= out
    total += in_
    mx = max(mx, total)

print(mx)




#print(ev(2) + ev(4) + ev(5))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

ev = lambda n: sum(i * (1/n) for i in range(1, n+1))

from collections import deque

if K == N:
    print(sum(ev(a) for a in A))

deq = deque()

while len(deq) < K:
    deq.append(ev(A.pop()))

total = sum(i for i in deq)
mx = total

while A:
    out = deq.popleft()
    in_ = ev(A.pop())
    deq.append(in_)
    
    total -= out
    total += in_
    mx = max(mx, total)

print(mx)

Submission status: Wrong Answer

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

    sumP = []
    for i, p in enumerate(P):
        sum_ = p*(p+1)/2/p
        if i == 0:
            sumP.append(sum_)
        else:
            sumP.append(sum_+sumP[-1])

    max_ = 0
    for i in range(len(sumP)-K):
        sub = sumP[i+K] - sumP[i]
        if sub > max_:
            max_ = sub

    print(max_)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
an = 0
if K == 1:
  ans = (max(p)+1)/2
  
  flag = False
else:
  ans = sum(p[0:K])
  an = ans
  for i in range(0,N-K):
    an = an +p[i+K] -p[i]
    ans = max(ans,an)
num = ans/2 + K/2    
print(num)

Submission status: Wrong Answer

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

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


sums=0
maxi=0

for i in range(0,n-k+1):
    for j in range(i,i+k):
        sums=sums+p[j]
    if sums>=maxi:
        maxi=sums
        sums=0

print((maxi+k)/2)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
an = 0
if K == 1:
  ans = (max(p)+1)/2
  print(ans)
else:
  for i in range(N-K+1):
    su = sum(p[i:i+K])
    print(su)
    if su > an:
      an = su
      print("kousin")
    if i+K+1 <= N-1:
      su -= p[i] - p[i+K+1]
  ans = an/2 + K/2

  print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
an = 0
if K == 1:
  ans = (max(p)+1)/2
  
  flag = False
else:
  for i in range(N-K+1):
    su = sum(p[i:i+K])
    print(su)
    if su > an:
      an = su
      print("kousin")
    if i+K+1 <= N-1:
      su -= p[i] - p[i+K+1]
  ans = an/2 + K/2
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
p = list(map(int, input().split()))
from itertools import accumulate
cum = list(accumulate(p))
ans = 0
for i in range(n-k):
    ans = max(ans, cum[i+k]-cum[i])
print((ans+k)/2)

Submission status: Wrong Answer

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

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

print(max([sum(e[i:i+k]) for i in range(n-k+1)]))

Submission status: Wrong Answer

Solution code:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

N,K = Line[0],Line[1]

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

max_dice = sum(Line[0:K-1])

for q in range(N-K):
    i = q+1
    # print(Line[q+K])
    if Line[i-1] >= Line[q+K]:
        continue
    
    dices = sum(Line[i:i+K])
    # print(dices)
    if dices > max_dice:
        max_dice = dices
# print(max_dice)

max_dice += K

print(max_dice/2)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
l=[]
for i in p:
  l.append(float((i+1)/2))
t=np.cumsum(np.array(l))
for j in range(n-k):
  ans=max(ans,t[j+k]-t[j])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
l=[]
for i in p:
  l.append((i+1)/2)
t=np.cumsum(np.array(l))
for j in range(n-k):
  ans=max(ans,t[j+k]-t[j])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = 0
for i in range(n-k):
    if i == 0:
        for j in range(k):
            candidate += (num_list[j]+1)/2
        tmp = candidate
    else:
        tmp += -(num_list[i-1]+1)/2 + (num_list[i+k]+1)/2
        if tmp > candidate:
            candidate = tmp
        
print(candidate)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = 0
for i in range(n-k):
    if i == 0:
        for j in range(k):
            candidate += (num_list[j]+1)/2
        tmp = candidate
        print(candidate)
    else:
        tmp += -(num_list[i-1]+1)/2 + (num_list[i+k]+1)/2
        if tmp > candidate:
            candidate = tmp
        
print(candidate)

Submission status: Wrong Answer

Solution code:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
result = 0
temp = sum(d)
popleft = d.popleft
dappend = d.append
for el in p[k:]:
    temp -= popleft()
    dappend(el)
    temp += el
    if result < temp:
        result = temp
print(result)

Submission status: Wrong Answer

Solution code:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
result = 0
popleft = d.popleft
dappend = d.append
for el in p[k:]:
    popleft()
    dappend(el)
    work = sum(d)
    if result < work:
        result = work
print(result)

Submission status: Wrong Answer

Solution code:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
temp1 = deque()
temp2 = deque()
i = 0
result = sum(d)
for el in p[k:]:
    temp1.append(el)
    temp2.append(d[i])
    i += 1
    work = result + sum(temp1) - sum(temp2)    
    if result < work:
        result = work
        for j in range(i):
            d.popleft()
            d.append(temp1.popleft())
        i = 0
        temp2.clear()
    if i == k:
        temp1.clear()
        temp2.clear()
        i = 0
print(result)

Submission status: Wrong Answer

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

S = [0]
E = []

for i in range(N+1):
    S.append(sum(p[0:i]))

for i in range(N-K+1):
    E.append(S[i+K]-S[i])


print((max(E)+K)/2)

Submission status: Wrong Answer

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

S = [0]
E = []

for i in range(N):
    S.append(sum(p[0:i]))

for i in range(N-K+1):
    E.append(S[i+K]-S[i])


print((max(E)+K)/2)

Submission status: Wrong Answer

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

S = [0]
E = []

for i in range(N):
    S.append(sum(p[0:i]))

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

print((max(E)+K)/2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
from collections import deque
l = []
for i in range(len(li)):
    l.append((1+ li[i])/2)
M = 0
from itertools import accumulate
a = list(accumulate(l))
for i in range(len(a)-y):
    m = a[i+y] - a[i]
    if m > M:
        M = m
print(M)

Submission status: Wrong Answer

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

r=[0]*(n+1)
s=0
for i in range(n):
    s+=p[i]
    r[i+1]=s
print(r)

def kitaichi(x):
    return (k+x)/2

ans=0
for i in range(n-k+1):
    kitai=r[i+k]-r[i]
    ans=max(kitai,ans)
print(kitaichi(ans))

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort(reverse=1)
print((sum(p[:k])+k)/2)

Submission status: Wrong Answer

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

P = sum(p[:K])
n = 0
for i in range(1, N-K+1):
  a = P - p[i-1] + p[i+K-1]
  if P < a:
   P = a
   n = i

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

Submission status: Wrong Answer

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

P = sum(p[:K])
n = 0
for i in range(1, N-K+1):
  a = P - p[i-1] + p[i+K-1]
  if P < a:
   P = a
   n = i

def allsum(x):
  return x * (x+1) // 2

ans = 0
for j in range(K):
  ans += allsum(p[n+j]) / p[n+j]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
res = 0
table = [0] * (max(a) + 1)
for i in range(1, max(a) + 1): table[i] = (i + 1) / 2
for _ in range(K): res += table[a.pop()]
print(res)

Submission status: Wrong Answer

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

max_sum_val = 0
sum_list = []
for j in range(len(p) - K + 1):
    sum_list.append(sum(p[j:K+j]))
index = np.argmax(np.array(sum_list))

plist = p[index:K+index]
prod = np.prod(np.array(plist))
sum_val = 0
for i in range(len(plist)):
    sum_val += prod * (plist[i] + 1) / 2 
print(sum_val / prod)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
max_val = 0
for j in range(len(p) - K + 1):
    plist = p[j:K+j]
    prod = np.prod(np.array(plist))
    sum_val = 0
    for i in range(len(plist)):
        sum_val += prod * (plist[i] + 1) / 2 
    max_val = max(sum_val / prod, max_val)
print(max_val)

Submission status: Wrong Answer

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

res = []

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
  #res.append(res[i-1] + p[i]*(p[i]+1)/(2*p[i]))
  res.append(res[i-1] + 0.5*(p[i]+1))
  #res.append(res[i-1] + 1 + 0.5*(p[i]-1))

ans=0

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

Submission status: Wrong Answer

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

res = []

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
  #res.append(res[i-1] + p[i]*(p[i]+1)/(2*p[i]))
  res.append(res[i-1] + 0.5*(p[i]+1))
  #res.append(res[i-1] + 1 + 0.5*(p[i]-1))

ans=0

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

Submission status: Wrong Answer

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

expect=[(dice+1)/2 for dice in p]
for i in range(N-1):
    expect[i+1]+=expect[i]
print(expect)
plus_p=[expect[K-1]]
for i in range(1, N-K+1):
    plus_p.append(expect[i+K-1]-expect[i-1])
print(max(plus_p))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
p2 = (p1+1) / 2
p3 = np.array([np.sum(p2[i:i+K],dtype=np.float32) for i in range(N-K+1)])
print(np.amax(p3))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = [(int(i)+1)/2 for i in input().split()]

wa_temp = sum(P[0:K])
max_wa = wa_temp

for i in range(N-K):
    wa_temp = wa_temp - P[i] + P[i+K]
    if wa_temp > max_wa:
        max_wa = wa_temp
    print(max_wa)
print(max_wa)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

rem = K
sum = 0.0
while rem > 0:
    #print(dict)
    key = max(list(dict.keys()))
    if rem - dict[key] > 0:
        rem = rem - dict[key]
        sum += ((key * (key+1)) / (2 * key)) * dict[key]
        dict.pop(key)
        #print(sum)
    else:
        sum += ((key * (key+1)) / (2 * key)) * rem
        break

print(sum)

Submission status: Wrong Answer

Solution code:
class BIT:
    def __init__(self, n):
        self.node = [ 0 for _ in range(n+1) ]

    def add(self, idx, w):
        i = idx
        while i < len(self.node) - 1:
            self.node[i] += w
            i |= (i + 1)

    def sum_(self, idx):
        ret, i = 0, idx-1
        while i >= 0:
            ret += self.node[i]
            i = (i & (i + 1)) - 1
        return ret

    def sum(self, l, r):
        return self.sum_(r) - self.sum_(l)


n, k = map(int, input().split())
tree = BIT(n)
p = [ int(x) for x in input().split() ]

for i in range(n):
    tree.add(i, (1+p[i])/2)

ans = 0
for i in range(n-k+1):
    ans = tree.sum(i, i+k)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

sum = 0.0
for i in range(K):
    pick = max(list(dict.keys()))
    sum += (pick * (pick+1)) / (2 * pick)
    dict[pick] = dict[pick] - 1
    if dict[pick] == 0:
        dict.pop(pick)
print(sum)

Submission status: Wrong Answer

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

E = [0] * N
for i in range(N):
  for j in range(p[i]):
    E[i] += (j+1) / p[i]
    
ans = 0
for i in range(N-K+1):
  e = 0
  for j in range(i, K):
    e += E[j]
  if ans < e:
    ans = e
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 0

expect_list = []
# 全部の期待値を求めた
for p in p_list:
  expect_list.append((p + 1) / 2)

# print(expect_list)

# 累積値を求めよう
accum_list = []
i = 0
while i < n:
  accum_list.append(sum(expect_list[0:i+1]))
  i += 1

# print(accum_list)

i = k - 1
max = 0
while i < n:
  dif = accum_list[i] - accum_list[i - k]
  if max < dif:
    max = dif
  i += 1

print(max)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# 左からa番目のサイコロの期待値
kitaiti = []

# kitaiti.append ( sum([ j for j in range(1,i +1)] ) /i)
#kitaiti =[ sum([ j for j in range(1,i +1)] ) /i  for i in A ]
kitaiti =[ (1 + i) /2  for i in A ]

# 隣接するK個の期待値を足す
sum_K =[]
sum_K = [float( sum(kitaiti[i:K +i]) ) for i in range(K) ] 
sum_K_max = max(sum_K)
# print(kitaiti)
# print(sum_K)
print(sum_K_max)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# 左からa番目のサイコロの期待値
kitaiti = []

# kitaiti.append ( sum([ j for j in range(1,i +1)] ) /i)
kitaiti =[ sum([ j for j in range(1,i +1)] ) /float(i)  for i in A ]

# 隣接するK個の期待値を足す
sum_K =[]
sum_K = [float( sum(kitaiti[i:K +i]) ) for i in range(K) ] 
sum_K_max = max(sum_K)
# print(kitaiti)
# print(sum_K)
print(sum_K_max)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# 左からa番目のサイコロの期待値
kitaiti = []

# kitaiti.append ( sum([ j for j in range(1,i +1)] ) /i)
kitaiti =[ sum([ j for j in range(1,i +1)] ) /i for i in A ]

# 隣接するK個の期待値を足す
sum_K =[]
sum_K = [sum(kitaiti[i:K +i])  for i in range(K) ]
sum_K_max = max(sum_K)
# print(kitaiti)
# print(sum_K)
print(sum_K_max)

Submission status: Wrong Answer

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))

# 左からa番目のサイコロの期待値
kitaiti = []
for i in A:
    kitaiti.append( sum([ j for j in range(1,i +1)] ) /i)

# 隣接するK個の期待値を足す
sum_K =[]
sum_K = [sum(kitaiti[i:K +i])  for i in range(K) ]
sum_K_max = max(sum_K)
# print(kitaiti)
# print(sum_K)
print(sum_K_max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

e = []
max_ = 0
sum_ = 0
f = []
e = [(1+p[i])/2  for i in range(n)]
for i in range(n):
    if i < k:
        sum_ += e[i]
    else:
        sum_ = sum_ + e[i] - e[i - k]
        max_ = max(max_, sum_)

print(max_)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split(" "))
c = list(map(int,input().split(" ")))
ans = 0
kar = 0
for i in range(n):
    c[i] = (c[i]+1)/2

for i in range(n):
    if i + 1 <= k:
        kar += c[i]
    else:
        kar += c[i] - c[i-k]
        if ans <= kar:
            ans = kar
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
lst2 = [(1 + lst[0]) / 2]
for x in lst[1:]:
    lst2.append(lst2[-1] + ((1 + x) / 2))

ret = 0
for idx, x in enumerate(lst2[0:-K]):
    ret = max(ret, lst2[idx + K] - x)
print(ret)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
#abc154d
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))
e=[]
for i in range(n):
 e.append((p[i]+1)/2)
c=[e[0]]
for i in range(1,n):
 c.append(c[i-1]+e[i])
res=0
for i in range(n-k):
 res=max(res,c[i+k]-c[i])
print("{:.7f}".format(res))

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split(' '))
data=list(map(int, input().split(' ')))
data=[(i+1)/2 for i in data]
s=[]
print(data)
for i in range(0,N-M+1):
    #print(data[i:i+M])
    s.append(sum(data[i:i+M]))
print(max(s))

Submission status: Wrong Answer

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

for i in range(1, n-k+1):
    cur -= (a[i-1]+1)/2
    cur += (a[i+k-1]+1)/2
    maximum = max(maximum, cur)

print(maximum)

Submission status: Wrong Answer

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

for i in range(1, n-k+1):
    cur -= (a[i-1]+1)/2
    cur += (a[i+k-1])/2
    maximum = max(maximum, cur)

print(maximum)

Submission status: Wrong Answer

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

# estP = [-1]
def est(i):
    return 1.0 + (i - 1) * 0.5
# for i in range(1, 1001):
# print(i, sum([j * 1.0 / i for j in range(1, i + 1)]))
# estP.append(sum([j * 1.0 / i for j in range(1, i + 1)]))
# print(i, 1.0 + (i - 1) * 0.5)
# # print(estP)

# 普通に計算する
# - 2x10e5 の2重ループなのでTLE

# m = -1.0
# for i in range(N - K + 1):
#     vi = sum([est(P[j]) for j in range(i, i + K)])
#     m = max(vi, m)
# print(m)


# かしこい計算: 累積和
sumA = [est(P[0])]
for i in range(1, N):
    sumA.append(sumA[-1] + est(P[i]))
# print([est(P[i]) for i in range(N)])
# print(sumA)

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

Submission status: Wrong Answer

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

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

# ans[i] = iを含めてk個前までの期待値の総和
ans = [0 for i in range(n)]
ans[k-1] = sum(p[0:k])
for i in range(k,n) :
  ans[i] = ans[i-1] + p[i] - p[i-k]
  
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

answer = 0
total = sum(pp[:k])

for i in range(n-k):
    total = total - pp[i] + pp[i+k]
    answer = max(answer, total)

print((answer+k)/2)

Submission status: Wrong Answer

Solution code:
import math

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

ls = []
ans = 0
answer = 0

for i in range(n-k+1):
    print(i)
    total = 0
    for j in range(k):
        j += i
        total += pp[j]
    if ans <= total:
        ans = max(ans, total)
        num = i

for n in range(k):
    ls.append(pp[num+n])

for i in range(len(ls)):
    answer += sum([int(n) for n in range(1, ls[i]+1)])/ls[i]

print(answer)

Submission status: Wrong Answer

Solution code:
#154_D
n, k = map(int, input().split())
p = [(int(x)+1) / 2 for x in input().split()]
p.sort(reverse= True)
print(sum(p[:k]))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]
 
ll = [x // 2 * (x + 1) / x for x in ret_lst]
print(sum(ll))