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())
lst = list(map(int,input().split()))
E = []
for x in lst:
  E.append((1+x)/2)
s = 0
for i in range(n-2):
  if s < E[i]+E[i+1]+E[i+2]:
    s = E[i]+E[i+1]+E[i+2]
print(s)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

n, k = inpl()
p = inpl()
p.sort()
p.reverse()
ans = 0
for i in range(k):
    ans += (1 + p[i]) / 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = [0]*(n+1)

for i in range(n):
    s[i+1] = s[i] + p[i]
    
res = 0
for i in range(n-k):
    res = max(res,s[i+k]-s[i])
print("{:.10f}".format(res/2))

Submission status: Wrong Answer

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

s = [0]*(n+1)

for i in range(n):
    s[i+1] = s[i] + p[i]
    
res = 0
for i in range(n-k):
    res = max(res,s[i+k]-s[i])
print(res/2)

Submission status: Wrong Answer

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

d_tmp = sum(p[0:k])
d_max = 0
for i in range(n-k):
  d_tmp = d_tmp + p[k+i] - p[i]
  d_max = max(d_max,d_tmp)

ans = (d_max + k)/2
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

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

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

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

T = T[K:]

if N == K:
    print(sum(P))
else:
    print(max(T))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

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

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

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

T = T[K:]

if N == 1:
    print(P[i])
else:
    print(T)

Submission status: Wrong Answer

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

def s(x):
    t = 0
    for i in range(x):
        t += i+1
    return t/x


for i in range(0, k):
    ans = s(P[i])

for j in range(1, n-k+1):
    t = 0
    for i in range(j, j+k):
        t += s(P[i])
    if ans < t:
        ans = t
print(ans)

Submission status: Wrong Answer

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

P[0] = (P[0]+1.)/2
for i in range(1,len(P)):
    P[i] = (P[i]+1.)/2
    P[i] = P[i-1]+P[i]

ans = 0.

if n==1:
    ans = P[0]

elif len(P)-k==0:
    ans = P[k-1] - P[0]
else:
    for i in range(len(P)-k):
        ans = max(ans,(P[i+k]-P[i]))
        
    
print(ans)

Submission status: Wrong Answer

Solution code:
from numpy import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = (N-K+1)*[0]
R = sum(P[0:K])
Q[0] = R

for n in range(1,N-K+1):
  Q[n] = R+P[n-1+K]-P[n-1]

R = argmax(Q)
print(0.5*(sum(P[R:R+K])+K))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = [float(x) for x in input().split()]
ep = [0 for x in range(N)]
for i in range(N) :
    ep[i] = (1.0+p[i])

epsum = 0
for i in range(K) :
    epsum += ep[i]

result = 0
buf = epsum
#print(ep)
#print(epsum)
for i in range(N-K) :
    buf = buf - ep[i] + ep[i+K]
    #print(buf)
    result = max(result,buf)

print(result * 0.5)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = [int(x) for x in input().split()]
ep = [0 for x in range(N)]
for i in range(N) :
    ep[i] = (1+p[i])

epsum = 0
for i in range(K) :
    epsum += ep[i]

result = 0
buf = epsum
for i in range(N-K) :
    buf = buf - ep[i] + ep[i+K]
    result = max(result,buf)

print(result * 0.5)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = [int(x) for x in input().split()]
ep = [0 for x in range(N)]
for i in range(N) :
    ep[i] = (1+p[i]) * 0.5

epsum = 0
for i in range(K) :
    epsum += ep[i]

result = 0
buf = epsum
for i in range(N-K) :
    buf = buf - ep[i] + ep[i+K]
    result = max(result,buf)

print(result)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    N, K = MI()
    P = LI()
    a = sum(P[0:K])
    Sums = []
    Sum = 0
    for i in range(N):
        Sum += P[i]
        Sums.append(Sum)
    ans = [0, 0, 0]
    for i in range(K, N):
        X = Sums[i] - Sums[i - K]
        if X > ans[0]:
            ans[0] = X
            ans[1] = i - K + 1
            ans[2] = i
    cnt = 0
    for i in range(ans[1], ans[2] + 1):
        cnt += (P[i] + 1) / 2
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
     N, K = MI()
     P = LI()
     a = sum(P[0:K])
     ans = [a, 0, K - 1]
     for i in range(K, N):
         if P[i] > P[i - K]:
             a = a - P[i - K] + P[i]
             ans[0] = a
             ans[1] = i - K + 1
             ans[2] = i
     cnt = 0
     for i in range(ans[1], ans[2] + 1):
         cnt += (P[i] + 1) / 2
     print(cnt)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))

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

total_K = 0
max_i = 0
for i in range(N-K+1):
  if i == 0:
    total_K = total[K-1]
  else:
    if total[i+K-1] - total[i-1] > total_K:
      max_i = i

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
lst = [0] * max(p)
for i in range(n):
    num = p[i]
    if lst[num - 1] == 0:
        num_temp = 0
        for j in range(1, num + 1):
            num_temp += ((1 / num) * j)
        lst[num - 1] = num_temp

if k  == 1:
  print(max(lst))
  exit()

ans = 0
for i in range(k):
    ans += lst[p[i] - 1]

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

Submission status: Wrong Answer

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

P[0] = (P[0]+1.)/2
for i in range(1,len(P)):
    P[i] = (P[i]+1.)/2
    P[i] = P[i-1]+P[i]

ans = 0.

if n==1:
    ans = P[0]

elif len(P)-k==0:
    ans = P[k-1] - P[0]
else:
    for i in range(len(P)-k):
        ans = max(ans,(P[i+k]-P[i]))
        
    
print(ans)

# https://atcoder.

Submission status: Wrong Answer

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

P[0] = (P[0]+1.)/2
for i in range(1,len(P)):
    P[i] = (P[i]+1.)/2
    P[i] = P[i-1]+P[i]

ans = min(P)
for i in range(len(P)-k):
    ans = max(ans,(P[i+k]-P[i]))
    
print(ans)

Submission status: Wrong Answer

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

P[0] = (P[0]+1.)/2
for i in range(1,len(P)):
    P[i] = (P[i]+1.)/2
    P[i] = P[i-1]+P[i]

ans = 0.
for i in range(len(P)-k):
    ans = max(ans,(P[i+k]-P[i]))
    
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    lst = []

    for i in range(n):
        lst.append((p_lst[i] + 1) / 2)

    tmp_sum = sum(lst[:k])
    maximum = tmp_sum
    for i in range(n - k):
        tmp_sum -= lst[i]
        tmp_sum += lst[i + k]
        maximum = max(maximum, tmp_sum)

    print(maximum)
    print(lst)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    lst = []

    for i in range(n):
        lst.append((p_lst[i] + 1) / 2)

    maximum = 0
    tmp_sum = sum(lst[:k])
    for i in range(n - k):
        tmp = tmp_sum
        tmp_sum -= lst[i]
        tmp_sum += lst[i + k]

        maximum = max(tmp_sum, tmp)

    print(maximum)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))

    tmp_lst = p_lst[:k]
    tmp_sum = sum(tmp_lst)
    for i in range(n - k):
        tmp = tmp_sum
        tmp_sum -= p_lst[i]
        tmp_sum += p_lst[i + k]

        if tmp_sum > tmp:
            tmp_lst = p_lst[i + 1: i + k + 1]

    maximum = 0
    for i in range(k):
        number = tmp_lst[i]
        maximum += (number + 1) / 2

    print(maximum)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))

    tmp_lst = p_lst[:k]
    tmp_sum = sum(tmp_lst)
    for i in range(n - k):
        tmp = tmp_sum
        tmp_sum -= p_lst[i]
        tmp_sum += p_lst[i + k]

        if tmp_sum > tmp:
            tmp_lst = p_lst[i + 1: i + k + 1]

    maximum = 0
    for i in range(k):
        number = tmp_lst[i]
        maximum += number * (number + 1) / 2 / number

    print(maximum)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

lis=[0]*(n+1)
for i in range(n):
  lis[i+1]=lis[i]+l[i]
  
ans=0
for i in range(n-k+1):
  num=lis[i+k]-lis[i]
  ans=max(num,ans)
  
print(ans)

Submission status: Wrong Answer

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

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

ans=0

for i in range(n-k+1):
  num=lis[i+k]-lis[i]
  ans=max(num,ans)
  
print(ans/2)

Submission status: Wrong Answer

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

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

ans=0

for i in range(n-k):
  num=lis[i+k]-lis[i]
  ans=max(num,ans)
  
print(ans/2)

Submission status: Wrong Answer

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

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

ans=0

for i in range(n-k):
  num=lis[i+k]-lis[i]
  ans=max(num,ans)
  
print(ans/2)

Submission status: Wrong Answer

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

lis=[0]*n
for i in range(len(l)):
  lis[i]+=(l[i]+1)/2+lis[i-1]

ans=0

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

Submission status: Wrong Answer

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

lis=[(i+1)/2 for i in l]
ans=0

for i in range(n-k):
  l=lis[i:i+k]
  num=sum(l)
  ans=max(num,ans)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)

l=l[0:k]
max_l=max(l)

num=0
sum_lis=[]
for i in range(1,max_l+1):
  num+=i
  sum_lis.append(num)
  
ans=0
for i in l:
  a=sum_lis[i-1]
  ans+=(a/i)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)

l=l[0:k]
max_l=max(l)

num=0
sum_lis=[]
for i in range(1,max_l+1):
  num+=i
  sum_lis.append(num)
  
ans=0
for i in l:
  a=sum_lis[i-1]
  ans+=(a/i)
  print(ans,i,a)
  
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    import numpy as np

    def expected_val(limit):
        return sum(range(1 + limit)) / limit

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

    lst = [0]
    lst = np.zeros(N + 1)
    res = 0
    for i in range(N):
        res += expected_val(P[i])
        lst[i] = res
    print(np.max(lst[K:] - lst[:N - K + 1]))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = [0]
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    if N - K == 0:
        print(lst[0])
        return
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    if N - K == 0:
        print(lst[0])
        return
    ans = 0
    for i in range(N - K):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) * limit ** -1

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    if N - K == 0:
        print(lst[0])
        return
    ans = 0
    for i in range(N - K):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    if N - K == 0:
        print(lst[0])
        return
    ans = 0
    for i in range(N - K):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K):
        ans = max(ans, lst[i + K] - lst[i])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

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

    lst = []
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K):
        for k in range(K + 1):
            ans = max(ans, lst[i + k] - lst[i])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = [(p+1)*0.5 for p in map(int, input().split())]

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

print(ans)

Submission status: Wrong Answer

Solution code:
"""
Created on Mon Sep  7 22:29:36 2020

@author: liang
"""
N, K = map(int, input().split())

P = [1 + (int(p)-1)*0.5 for p in input().split()]
#print(P)

tmp = sum(P[:K])
ans = 0
for i in range(N-K):
    tmp += P[K+i] - P[i]
    if tmp > ans:
        ans = tmp
    
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 22:29:36 2020

@author: liang
"""
N, K = map(int, input().split())

P = [1 + (int(p)-1)*0.5 for p in input().split()]
print(P)

tmp = sum(P[:K])
ans = 0
for i in range(N-K):
    tmp += P[K+i] - P[i]
    if tmp > ans:
        ans = tmp
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
l=[]
A=0
for i in range(K):
  l.append(max(P))
  P.remove(max(P))
for i in range(len(l)):
  A=A+l[i]*(l[i]+1)/(2*l[i])
  
print(A)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
mem = 0
mem1,ans= [],[]
P.sort(reverse=True)


for n in range(K-1):
    for k in range(1,P[n]+1):
        mem += k
    mem1.append(mem)
    mem = 0

for n in range(len(mem1)):
    ans.append(mem1[n] / P[n])
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
P = list(map(int, input().split()))
mem = 0
mem1,ans= [],[]
P.sort(reverse=True)


for n in range(K):
    for k in range(1,P[n]+1):
        mem += k
    mem1.append(mem)
    mem = 0

for n in range(len(mem1)):
    ans.append(mem1[n] / P[n])
print(sum(ans))

Submission status: Wrong Answer

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

# Piの期待値 (1 + Pi) // 2
E = list(map(lambda x: (x + 1) / 2, P))
E_SUMS = [E[0]]
for i in range(1, N):
    E_SUMS.append(E_SUMS[i - 1] + E[i])

m = 0
for i in range(K, N):
    m = max(m, E_SUMS[i] - E_SUMS[i - K])

print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
data=list(map(float,input().split()))
new_data=[0]*n
for i in range(n):
    new_data[i]=(data[i]+1)/2
temp=0
for i in range(k):
    temp+=new_data[i]
ans=0
for i in range(n-k):
    temp=temp-new_data[i]+new_data[i+k]
    ans=max(ans,temp)
print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
data=list(map(float,input().split()))
new_data=[0]*n
for i in range(len(data)):
    new_data[i]=(data[i]+1)/2
temp=0
for i in range(k):
    temp+=new_data[i]
ans=0
for i in range(k,len(data)):
    temp=temp-new_data[i-k]+new_data[i]
    ans=max(ans,temp)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
data=list(map(int,input().split()))
new_data=[0]*n
for i in range(len(data)):
    if data[i]==1:
        new_data[i]=1
        continue
    new_data[i]=(data[i]+1)/2
temp=0
for i in range(k):
    temp+=new_data[i]
ans=0
for i in range(k,len(data)):
    temp=temp-new_data[i-k]+new_data[i]
    ans=max(ans,temp)
print(ans)

Submission status: Wrong Answer

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

e = sum(range(1,p[0]+1))/p[0]
S = [e]

for i in range(1,N):
    ex = p[i]*(p[i]+1) / (2*p[i])
    S.append(ex + S[i-1])

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

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] = (1+p[i])/2

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

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

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

# 累積和を用いる
S = [0]*N
S[0] = p[0]
for i in range(N-1):
  S[i+1] = S[i] + p[i+1]

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

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

# 累積和を用いる
S = [0]*N
S[0] = p[0]
for i in range(N-1):
  S[i+1] = S[i] + p[i+1]
print(p, S)

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

print(ans)

Submission status: Wrong Answer

Solution code:
def Ex(x):
    return (x+1)
N,K = map(int,input().split())
plist = list(map(int,input().split()))
Alist = [0]*N
Ans = sum(plist[0:K])
An = [0,K]
for j in range(0,N-K+1):
    Ans2 = Ans - plist[j-1] + plist[K+j-1] 
    if Ans != max(Ans,Ans2):
        Ans = max(Ans,Ans2)
        An = [j,j+K]
Answer = 0
for i in plist[An[0]:An[1]]:
    Answer += Ex(i)
print(Answer/2)

Submission status: Wrong Answer

Solution code:
def Ex(x):
    return (1/2)*(x+1)
N,K = map(int,input().split())
plist = list(map(int,input().split()))
Alist = [0]*N
Ans = sum(plist[0:K])
An = [0,K]
for j in range(0,N-K+1):
    Ans2 = Ans - plist[j-1] + plist[K+j-1] 
    if Ans != max(Ans,Ans2):
        Ans = max(Ans,Ans2)
        An = [j,j+K]
Answer = 0
for i in plist[An[0]:An[1]]:
    Answer += Ex(i)
print(Answer)

Submission status: Wrong Answer

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

ans = 10**10
for i in range(N-K):
  s = 0
  for j in range(K):
    s += p[i+j]/2
  ans = min(ans, s)
  
print(ans)

Submission status: Wrong Answer

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

P = [((x+1) * x / 2) / x for x in P]
A = list(accumulate(P))

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

print(ans)

Submission status: Wrong Answer

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

a = sum(p[:K])
s = sum(p[:K])
for i in range(K, N):
    s += p[i] - p[i - K]
    a = max(a, s)
    print(s)

ans = (a + K) / 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort(reverse=True)
print((sum(p[:k])+k)/2)

Submission status: Wrong Answer

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

res = 0

P2 = []
for i in P:
  P2.append(1 + 0.5 * (i - 1))
num = 0
for i in range(K):
  num += P2[i]
res = num
for i in range(1,N-K+1):
  temp = num + P2[i+K-1] - P2[i-1]
  if temp > num:
    res = temp
  num = temp
  
print(res)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

ans=0
q=deque(P[:K])
for n in range(K,N):
  q.popleft()
  q.append(P[n])
  ans=max(ans, sum(q))

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
cc = list(map(int,input().split()))
dice_sum = sum(cc[:K])
max_dice = dice_sum
for i in range(N-K):
  dice_sum = dice_sum + cc[i+K] - cc[i]
  max_dice = max(max_dice,dice_sum)
print((max_dice+K)//2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N,M=MAP()
L=LIST()
maxa=-(10**10)
sums=sum(L[:M])
for i in range(N-M):
  sums=sums-L[i]+L[i+M]
  maxa=max(maxa,sums)
print((maxa+M)/2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N,M=MAP()
L=LIST()
maxa=-1002
sums=sum(L[:M])+M
for i in range(N-M):
  sums=sums-L[i]+L[i+M]
  maxa=max(maxa,sums)
print(maxa/2)

Submission status: Wrong Answer

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

l = []
for i in p:
    l.append((1/2*i*(i+1))/i)

s = [0]*len(l)
s[0] = l[0]
for i in range(1,len(l)):
    s[i] = s[i-1]+l[i]

ans = 0
for i in range(K,len(s)):
    ans = max(ans,s[i]-s[i-K])

if N == K:
    print(min(p))
    exit()

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b
n,k=map(int,input().split())
p=Csum(list(map(int,input().split())))
ans=0
for i in range(n-k+1):
    ans=max(ans,p[i+k]-p[i])
print(ans)
print((ans+k)/2)

Submission status: Wrong Answer

Solution code:
def Csum(a):
    b,c=[0],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b
n,k=map(int,input().split())
p=Csum(list(map(int,input().split())))
ans=0
for i in range(n-k+1):
    ans=max(ans,p[i+k]-p[i])
print(ans//2+1)

Submission status: Wrong Answer

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

rui=[0]
for i in a:
  rui.append(rui[-1]+i)
hantei=0
for i in range(0,len(rui)-k):
  if hantei<=rui[i+k]-rui[i]:
    hantei=rui[i+k]-rui[i]
    l=i
    r=i+k
ans=0
print(l,r-1)
for i in range(l,r):
  ans+=(a[i]+1)/2
  
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
li.sort(reverse=True)
ans=0
for i in li[:k]:
  ans+=kai[i]/i
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(s) for s in input().split()]
b=[0]*k
c=0
v=[0]*n
v[0]=a[0]
for i in range(n-1):
    v[i+1]=v[i]+a[i+1]
mx=v[k-1]
for i in range(k,n):
    g=v[i]-v[i-k]
    print(mx)
    print(g)
    mx=max(mx,g)  
    
print((mx+k)/2)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for i in range(1000):
  ev.append(Decimal(Decimal(str(((i + 1) * (i + 2)) // 2)) / Decimal(i + 1)))
m = 0
ans = 0
for i in range(n):
  if i < k:
    m += ev[p[i] - 1]
  else:
    ans = max(m, m + ev[p[i] - 1] - ev[p[i - k] - 1])
    m = m + ev[p[i] - 1] - ev[p[i - k] - 1]
print(ans)

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if N==K:
        print(sum(D)/2)
        quit()
    if K==1:
        print(max(D)/2)
        quit()
        
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))

Submission status: Wrong Answer

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

    D = []
    for p in P:
        if p==1:
            D.append(p)
        else:
            D.append(1+p)
    if N==K:
        print(sum(D)/2)
        quit()
        
    ACC_D = []
    acc = 0
    for d in D:
        acc += d
        ACC_D.append(acc)

    ans = 0
    for i in range(N-K):
        ans = max(ans, (ACC_D[i+K]-ACC_D[i])/2)
    print('{:.10f}'.format(ans))