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

c=0

x=0

for i in range(1,n-k):
#  print(sum(p[x:x+k]),sum(p[i:i+k]))
  if sum(p[x:x+k])<sum(p[i:i+k]):
    x=i
#print(x)
for i in range(x,x+k):
  z=0
  for j in range(0,p[i]+1):
    z+=j
#  print(z)
#  print(p[i])
  c+=z/p[i]
print(c)

Submission status: Wrong Answer

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

p = sorted(p, reverse=True)

l = p[:K]

sum = 0
sum_p = 0

for i in l:
    for j in range(i):
        j += 1
        sum += j / i
    sum_p += sum
    sum = 0

print(sum_p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def kitai(a):
    tmp = 0
    # for a in A:
    tmp = 1/a * (1/2 * a * (a+1))
    return tmp
    
ans = 0
max_ruiseki = 0
max_index = 0
# left = 0
# right = k
max_ruiseki = sum(p[0:k])
now_ruiseki = 0
ruiseki = [max_ruiseki]
for left in range(n-k+1):
    if left != 0:
        right = k + left -1
        
        # print(right ,p[right])
        # print(left, p[left])
        new_ruiseki = ruiseki[left-1] + p[right] - p[left]
        ruiseki.append(new_ruiseki)

# print(ruiseki)
m = 0
max_index = 0
for i in range(len(ruiseki)):
    if m != max(m, ruiseki[i]):
        m = ruiseki[i]
        index = i

# print(index)

A = p[index:index+k]
    # now_ruiseki = max_ruiseki
for a in A:
    ans += kitai(a)
print(ans)

    



# next_ruiseki = 0
# for i in range(n-k+1):
#     next_ruiseki = ruiseki    
#     ruiseki = max(ruiseki)


    # A
    # A = p[i:i+k]
    # if c != max(c, sum(A)):
    #     c = sum(A)
    #     C = deepcopy(A)
# for a in C:
#     ans += kitai(a)
# print(ans)

Submission status: Wrong Answer

Solution code:
# D
N, K = map(int, input().split())
lst = list(map(int, input().split()))
lst1 = [(lst[0] + 1) / 2]
ma = 0
for i in range(1, len(lst)):
    lst1.append(lst1[i-1] + ((lst[i]+1) / 2))
    if (i >= K):
        ma = max(ma,lst1[i] - lst1[i-K])
print(ma)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#D - Dice in Line
N,K = map(int,input().split())
p = list(map(int, input().split()))
S = [0]*N
s = 0
s_t = 0
S[0] = (1+p[0])/2

if N == 1:
    print(S[0])
    exit()
else:
    pass

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

if N == K:
    print(sum(S))
    exit()
else:
    pass

for j in range(N-K):
    s_t = S[j+K]-S[j]
    if s_t >= s:
        s = s_t
    else:
        pass

print(s)

Submission status: Wrong Answer

Solution code:
i = input().split()
n = int(i[0])
nannko = int(i[1])
i2 = input().split()
nAr = [int(s) for s in i2]

for j in range(n - nannko + 1):
    li = nAr[j:j+nannko]
    sum = 0
    max = 0
    for k in range(len(li)):
        sum += (li[k] + 1)/2
        print(sum)
        if (sum > max):
        	max = sum
print(max)

Submission status: Wrong Answer

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

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

print(sum1)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * N
    answer = 0
    for i in range(N):
        if not i == 0:
            exceptation_sum[i] = (p[i] + 1) / 2 + exceptation_sum[i - 1]
        else:
            exceptation_sum[i] = (p[i] + 1) / 2
    for i in range(N - K + 1):
        answer = max(answer, exceptation_sum[i + K - 1] - exceptation_sum[i - 1])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))
l = [] * total

tar2 = 0
calc_before = 0
calc_now = 0
for i in range(total-tar):
  for j in range(tar):
    calc_now += dice_array[i + j]
  if calc_before < calc_now:
    tar2 = i
    calc_before = calc_now
  calc_now = 0
  
sum = 0
for i in range(tar2, tar+tar2):
  cnt = 0
  for j in range(1, dice_array[i]+1):
    cnt += j
  sum += (cnt / dice_array[i])
  
print(sum)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

S, T = list(map(int,(input().split())))
p = list(map(int,(input().split())))
ans = 0
anss = []
for i in range(T):
  ans = 0
#  print(p[i:T+i])
  for j in p[i:T+i]:
#    print(list(range(1,j+1)))
    temp_a = list(range(1,j+1))
    ans += sum(temp_a)/len(temp_a)
#    print(ans)
    anss.append(ans)
#  print(ans)  
  
  
  
print(max(anss)  )

Submission status: Wrong Answer

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

a = [(1+p[i])/2 for i in range(n)]
res = sum(a[0:k])

for i in range(k,n):
    if a[i-k]<a[i]:
        res = sum(a[i-k+1:i+1])
        ans = a[i-k+1:i+1]

print(res)

Submission status: Wrong Answer

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

P = []
for i in range(N):
    if p[i] == 1:
        P.append(1)
    else:
        P.append((p[i]+1)/2)

Max = 0
Max1 = 0
for i in range(N-K+1):
    Max1 = 0
    for k in range(i,i+K):
        print(k,P[k])
        Max1 += P[k]
    if Max1 > Max:
        Max = Max1
        Max1 = 0
    else:
        Max1 = 0

print(Max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
ps = list(map(lambda n: (int(n)+1)/2, input().split()))

mx = sum(ps[:k])
for i in range(1, n - (k-1)):
  if ps[i-1] < ps[i+k-1]:
    mx = sum(ps[i:i+k])
print(mx)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]
    sum1 = 0
    sum2 = 0
    sum3=0
    sum4 = []
    for i in range(b):
        j = a[i]
        sum1 =  j
        sum2 =  j *(2 + (j-1))/2
        sum3 = sum2/sum1
        sum4.append(sum3)
    max =0
    now =0
    count = 0
    for i in range(b):
        if count < c:
            count = count +1
            now = now + sum4[i]
        else:
            if i < b-c and i >c-1:
                now = now -sum4[i-c]+sum4[i]
                if max < now:
                    max = now

    print(max)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

import itertools as its
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(p):#期待値
    return ((p+1)/2)


#input
n,k=(pin())
S=list(pin())
debug(S)
s=([comp(S[_]) for _ in range(n)])
ans=0
#print(s)
x=list(its.accumulate(s))
#print(list(its.accumulate(s)))
#default
for a in range(k):
    ans=x[k-1]
print("*",ans,0,k-1)
temp=0.0
for i in range(1,n-k+1):
    
    ans=max(ans,x[k+i-1]-x[i-1])
print(ans)
#print(["NO","YES"][1-cond])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

exp={}

ans=0
cnt=0
for i in range(1,1001):
    sum=0
    for j in range(1,i+1):
        sum+=j
    exp[i]=sum/i

while cnt<=n-1-k:
    tmp=0
    for i in range(k):
        tmp+=exp[p[i+cnt]]
    if ans < tmp:
        ans=tmp
    cnt += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

import itertools as its
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(p):#期待値
    return ((p+1)/2)


#input
n,k=(pin())
S=list(pin())
debug(S)
s=([comp(S[_]) for _ in range(n)])
ans=0
#print(s)
x=list(its.accumulate(s))
print(list(its.accumulate(s)))
#default
for a in range(k):
    ans=x[k-1]
print("*",ans,0,k-1)
temp=0.0
for i in range(1,n-k+1):
    
    ans=max(ans,x[k+i-1]-x[i-1])
print(ans)
#print(["NO","YES"][1-cond])

Submission status: Wrong Answer

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

history = {}

top3 = []

result = 0

def calc_expect_sum(targets):
    return sum( (p+1) * 0.5 for p in targets)

prev_sum = calc_expect_sum(ps[0:0+k])
result = 0

for i in range(1,n-k+1):
    prev = ps[i-1]
    current = ps[i+k-1]
    diff = (current - prev) * 0.5
    new = prev_sum + diff
    if new > result:
        result = new
    prev_sum += diff

print(result)

Submission status: Wrong Answer

Solution code:
# D
N, K = map(int, input().split())
lst = list(map(int, input().split()))
lst1 = [(lst[0] + 1) / 2]
ma = 0
for i in range(1, len(lst)):
    lst1.append(lst1[i-1] + (lst[i]+1) / 2)
    if (i >= K-1):
        ma = max(ma,lst1[i] - lst1[i-K])
print(ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

NK=K
mo=1

answer=np.max([mo*np.sum(p[i:i+NK+1]) for i in range(NK)]) / 2

print(abs(answer) )

Submission status: Wrong Answer

Solution code:
n, k = input().split()
*N,  = map(int, input().split())
n = int(n)
k = int(k)
p = [0] * n
for i in range(n):
    p[i] = 1/2*N[i]*(N[i]+1)/N[i]
    
ind = p.index(max(p))

if ind-k < 0:
    s = 0
else :
    s = ind-k

if ind+k > n-1:
    p = p[s:]
else :
    p = p[s:ind+k]
    
sub = []
for j in range(len(p)-k+1):
    sub.append(sum(p[j:j+k]))

print(max(sub))

Submission status: Wrong Answer

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

array = P[0:K]
index = sum(P[0:K])

for i in range(1, len(P)-K+1):
    s = index - P[i-1] + P[i+K-1]
    if s >= index:
        index = s
        array = P[i:i+K]


ans = 0
for i in range(K):
    s = array[i]*(array[i]+1)/2
    ans += s / array[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=0
A,S=[0]*N,[0]*N
A[0]=S[0]=P[0]
for i in range(N-1):
    A[i+1]=P[i+1]
    S[i+1]=S[i]+A[i+1]

for i in range(N-K):
    tmp=(S[K+i]-S[i])/2+0.5*K
    if ans<tmp:
        ans=tmp
print(ans)

Submission status: Wrong Answer

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

import numpy as np

Ps = np.array(Ps)

Exp_each_p = (Ps + 1) /2

sum_Exp = [sum(Exp_each_p[0:k])]
for id in range(1, n - k - 1):
    sum_Exp.append(sum_Exp[id - 1] - Exp_each_p[id - 1] + Exp_each_p[id + k])

print(max(sum_Exp))

Submission status: Wrong Answer

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

ans = 0
i = 0 
while i < n-2:
    list_internal = list[i:k+i]
    e = 0
    j = 0
    while j < len(list_internal):
        e += (list_internal[j]+1)/2
        if ans <= e:
            ans = e
        j += 1
    i += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p_list.sort()
p_list.reverse()

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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


def calc_expected(pi):
    return (1+pi)*pi/2


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

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
s_max = 0
max_i=0
ret = 0
p_s=sum(p[0:k])
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)

Submission status: Wrong Answer

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

ma = 0
for i in range(1,n-k+1):
    ans=0
    for j in range(k):
        ans += 1+0.5*(p[i+j]-1)
    if(ma<ans):
        ma = ans
    
print(ma)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N-K+1):
    m = sum(p[i:i+K])
    if m > max_l:
        max_l = m
        Max_l = p[i:i+K]

L = list(map(lambda x:x+1,Max_l))

print(sum(L)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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


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

    m = 0
    for k in P[l_res+1:r_res+2]:
        m += ((k+1)/2)

    print(m)

Submission status: Wrong Answer

Solution code:
i = input().split()
n = int(i[0])
nannko = int(i[1])
i2 = input().split()
nAr = [int(s) for s in i2]

if (n == nannko):
  sum = 0
  for j in range(n):
    sum += (nAr[j] + 1)/2
  print(sum)
else:
  for j in range(n - nannko + 1):
    li = nAr[j:j+nannko]
    sum = 0
    max = 0
    for k in range(len(li)):
      sum += (li[k] + 1)/2
      if (sum > max):
        max = sum
  print(max)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

import itertools as its
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(p):#期待値
    return ((p+1)/2)


#input
n,k=(pin())
S=list(pin())
debug(S)
s=([comp(S[_]) for _ in range(n)])
ans=0
#print(s)
x=list(its.accumulate(s))
#print(list(its.accumulate(s)))
#default
for a in range(k):
    ans=x[k-1]
#print("*",ans,0,k-1)
temp=0.0
for i in range(1,n-k):
    
    ans=max(ans,x[k+i-1]-x[i-1])
print(ans)
#print(["NO","YES"][1-cond])

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def resolve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    best_idx = 0
    best_sum = 0
    best_ps = []

    cs = np.cumsum(P)

    for i in range(K-1, N):
        s = cs[i] - cs[i-K+1]
        if s > best_sum:
            best_sum = s
            best_idx = i

    def calc(p):
        if p % 2 == 0:
            return p/2 + 0.5
        else:
            return math.ceil(p/2)
        #pi = range(1, p+1)
        #return sum(pi) / len(pi)

    p_sum = 0
    for i in range(K):
        p_sum += calc(P[best_idx - i])

    print(p_sum)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# 連続する値のうち、数値が最大となるものを取得する
def get_max_index(n, k, arr):
    tmp = 0
    index = 0
    tmp_arr = []
    for i in range(n - (k - 1)):
        if sum(arr[i:i+k]) >= tmp:
            index = i
            tmp_arr = arr[i:i+k]
    ans = 0
    for j in tmp_arr:
        tmp_sum = 0
        for m in range(1, j+1):
            tmp_sum += m
        ans += float(tmp_sum / j)
    return ans

if __name__ == "__main__":
    n, k = map(int, input().split())
    arr = list(map(int,input().split()))
    print(get_max_index(n, k, arr))

Submission status: Wrong Answer

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

max_val = 0
max_idx = 0
for i in range(1,N-K+1):
  tmp = sum(p[i-1:i-1+K])
  if tmp > max_val:
    max_val = tmp
    max_idx = i
    
expect = 0.0
for i in range(max_idx, 2*max_idx+1):
  tmp = 0.0
  for j in range(1,p[i-1]+1):
    tmp += j
  expect += tmp/p[i-1]
print(expect)

Submission status: Wrong Answer

Solution code:
N = input()
M = list(map(int,input().split()))
X = set(M)
Y = len(X)

if N == Y:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation_sum = [0] * N
    answer = 0
    for i in range(N):
        if not i == 0:
            exceptation_sum[i] = (p[i] + 1) / 2 + exceptation_sum[i - 1]
        else:
            exceptation_sum[i] = (p[i] + 1) / 2
    for i in range(N - K):
        answer = max(answer, exceptation_sum[i + K - 1] - exceptation_sum[i - 1])
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

#素因数分解
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

#重複を検出
def has_duplicates(seq):
  return len(seq) != len(set(seq))



#X = str(input()).split()
#a = [int(x) for x in input().split()]


NK = str(input()).split()
N = int(NK[0])
K = int(NK[1])
p = [int(x) for x in input().split()]

M = 0
ans = 0

for i in range(K):
  M+= p[i]

ans = M
ans2 = 0
ans3 = 0
ans4 = 0

for i in range(K, N):
  if(ans < ans-p[i-K]+p[i]):
    ans2 = i-K+1
    ans = ans-p[i-K]+p[i]

for i in range(ans2,ans2+K):
  for j in range(p[i]+1):
    ans3 += j
  ans4 += ans3/p[i]
  ans3 = 0


print(ans4)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
elm = 0
for num in p:
    elm += (num * (num + 1) / 2) * (1 / num)
    nums.append(elm)
maxVal = 0
for i in range(n - k):
    if nums[i + k] - nums[i] >= maxVal:
        maxVal = nums[i + k] - nums[i]
    else:
        continue
print(maxVal)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
saidai = 0
wa =[None]*n
wa_2 = 0
gokei = 0
for i in range(n):
    gokei += p[i]
    wa[i] = gokei
for j in range(n-k):
    wa_2 = wa[j+k]-wa[j]
    if wa_2 > saidai:
        saidai = wa_2
kitai = (1/2)*(k+saidai)
print(str(kitai))

Submission status: Wrong Answer

Solution code:
import heapq
import functools
import operator

def culc_expected_value(num):
  output = 0
  if num != 1:
    for i in range(1, num+1):
      output += i/num
  else:
    output = 1
  return output
 
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_nums = 0
max_targets = []
prod = functools.partial(functools.reduce, operator.mul)
for j in range(0, len(p_list)-k-1):
  targets = [p_list[j+m] for m in range(k)]
  t_prod = prod(targets)
  if t_prod >= max_nums:
    max_nums = t_prod
    max_targets = targets
# print(max_targets)

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

print(ans)

Submission status: Wrong Answer

Solution code:
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
souwa=0
for i in range(q[0]-q[1]):
  k=0
  for j in range(q[1]):
    k+=w[i+j]
  if a<k:
    a=k
    memo=i
for p in range(q[1]):
  souwa+=(w[memo+p]+1)/2
print(souwa)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

import itertools as its
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def comp(p):#期待値
    return ((p+1)/2)


#input
n,k=(pin())
S=list(pin())
debug(S)
s=([comp(S[_]) for _ in range(n)])
ans=0
print(s)
x=list(its.accumulate(s))
print(list(its.accumulate(s)))
#default
for a in range(k):
    ans=x[k-1]
print("*",ans,0,k-1)
temp=0.0
for i in range(1,n-k):
    
    ans=max(ans,x[k+i-1]-x[i-1])
print(ans)
#print(["NO","YES"][1-cond])

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A=list(map(int, input().split()))  
 
num = sum(A[0:K])
ind = 0
max_num =0
for i in range(N-K):
    if A[i] < A[i+K]:
        num = sum(A[i:i+K])
        if num> max_num:
            ind = i+1
            max_num = num
 
ans = 0
for i in range(ind,ind+K):
    ans += sum(range(1,A[i]+1))/A[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=0
A,S=[0]*N,[0]*N
A[0]=S[0]=P[0]
for i in range(N-1):
    A[i+1]=P[i+1]
    S[i+1]=S[i]+A[i+1]

for i in range(N-K):
    tmp=S[K+i]-S[i]
    if ans<tmp:
        ans=tmp
print(ans/2+0.5*K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

P_ave_sum = []
ave = 0
for p in P:
    ave += (p + 1) / 2
    P_ave_sum.append(ave)



max = -1
for j in range(n - k):
    sum_k = P_ave_sum[j + k] - P_ave_sum[j]
    if sum_k > max:
        max = sum_k

print(max)